The consumer surplus is the difference between the highest price a consumer is willing to pay and the actual market price of the good. The producer surplus is the difference between the market price and the lowest price a producer would be willing to accept. For producers, surplus can be thought of as profit, because producers usually don't want to produce at a loss. The two together create economic surplus.

In economics, the intersection of the supply and demand curves gives the market price and quantity of a good. Before these two curves intersect, there is a space where the price customers are willing to pay for a given quantity is higher than the price suppliers would be willing to accept. At the market price, then, there is a surplus for both parties: consumers who would have paid more only have to pay the market price, and suppliers who would have accepted less receive the market price. The extra value that both consumer and suppliers get in the transaction is referred to as surplus.

There are declining returns to consumption, which is why the demand curve is downward-sloping. As the quantity of a good in the market increases, its marginal benefit decreases. As such, the consumer surplus for a given quantity declines as it approaches the actual market price and quantity.

If a producer can perfectly price discriminate, it could theoretically capture the entire economic surplus. Perfect price discrimination would entail charging every single customer the maximum price he would be willing to pay for the product. (For related reading, see: How do companies benefit from price discrimination?)