A codpiece is a flap or pouch that attaches to the front of the crotch of men's pants to provide a covering for the genitals. It would be held closed by string ties, buttons, or other methods.

At one time, it was an important item of European clothing in the Fifteenth and Sixteenth Centuries.

At first, the codpiece was entirely a practical matter of modesty. Men's hose were typically very snug on the legs and open at the crotch, with the genitalia simply hanging loose under the doublet. A shortening of the doublet resulted in often-exposed genitalia, so the codpiece came into being (there are other versions of the origin of the codpiece).

As time passed, codpieces were shaped to emphasize the male genitalia and eventually often became padded and bizarrely shaped. They also often doubled as pockets, handy carrying places for a variety of items.