Although leeks are related to garlic and onions, they’re distinctly different. They have a mild flavor and firm texture that works well with rich and creamy dishes such as potato gratin. While nothing tastes exactly like leeks, in a pinch you can replace them with other ingredients, but the dish will taste noticeably different than if you had used leeks.
Onions have a stronger, more pungent flavor than leeks. They work well in most recipes that include leeks because they have a similar amount of bulk. Red and white onions are too sharp to closely approximate the flavor of leeks, so use yellow onions, if possible. Any of these onions will work to some extent, but you should expect a more intense flavor from the red and white varieties. Try sauteing the onions before adding them to the dish to temper the flavor and make them somewhat sweeter.
Garlic works well as a substitute for leeks in cases where the flavor is more important than the volume. Adding the same amount of garlic as leeks would wreak havoc on most recipes — 1 pound of leeks might work well in a potato leek soup, for example, but adding 1 pound of garlic instead would create a nearly inedible garlic soup with potato. Because you cannot add as much garlic as leeks, you may need to cut back the liquid or add more of the solid ingredients in the recipe to compensate.
Shallots are perhaps the best possible substitution for leeks. They have a similarly delicate texture to properly cooked leeks, and their flavor is mild enough that you do not need to worry about overwhelming the dish. Slice the shallots thinly and add them to the recipe as you would add leeks. Use slightly less than the recipe calls for in leeks — replace 1 cup of leeks with about 2/3 to 3/4 cup of shallots.
References and ResourcesTexas A&M Aggie Horticulture: Leeks
University of California Good Life Garden: Leeks
Gourmet Sleuth: Leeks
Cook's Thesaurus: Green Onions & Leeks