Baking powder and baking soda are two of the most important ingredients on the baker’s shelf. The advent of these chemical leaveners — as opposed to relying on naturally occurring yeast or the extensive beating of air into eggs or batter — put reliable, convenient baking into the hands of even the most novice cook. (The creation and marketing of baking powder was so seminal and dramatic that food historian Linda Civitello wrote a whole book, “Baking Powder Wars,” on it.)

The fact that they serve a similar purpose, and overlap in their composition, can be confusing. While both are used to generate rise in baked goods, they work in slightly different ways with different ingredients. Subbing one for the other, without accounting for those differences, can prove disastrous. Here’s what you need to know about these pantry staples.

Baking soda is pure sodium bicarbonate. It is alkaline, which means it has a pH above the neutral 7 and reacts with acidic ingredients. Think about the old baking soda-and-vinegar school experiment.

Baking powder is an all-in-one leavener, meaning it includes baking soda and the “exact amount of acid to use up all the soda,” Shirley Corriher says in “CookWise: The Hows and Whys of Successful Cooking.” Baking powder also includes a hefty amount of cornstarch, which helps absorb moisture to stave off premature reactions, as some of the acids in baking powder are activated in the presence of liquid.

How they work. Both leaveners work when they are broken down and release carbon dioxide. That gas is what contributes to the rise of baked goods. “Neither chemical leaveners nor steam create a single new bubble. They only enlarge bubbles that already exist in the dough,” Corriher says in “BakeWise: The Hows and Whys of Successful Baking.” That means that adding them to your dough or batter won’t automatically make them rise. You must still pay attention to the mixing method in a recipe, such as creaming butter and sugar, to create the air bubbles that the leaveners will inflate.

Baking soda will begin acting immediately in the presence of an acid, which means you need to act quickly with recipes that rely on it alone. While buttermilk, citrus and yogurt are obvious triggers, baking employs a variety of other acidic ingredients that you should be aware of, including honey, brown sugar, molasses and chocolate.

Most store-bought baking powder is double-acting and contains a blend of salt acids in which some react quickly, in the presence of liquid, and others more slowly, in the presence of heat, i.e., the oven. That generally buys you a bit more time, though you still shouldn’t wait too long to get those batters baking.

How much to use. Corriher says she finds many recipes are over-leavened. People seem to think that fallen cakes, for example, mean they need more leavening, but the opposite is true. “The bubbles get big, float to the top and pop. The baked goods get heavy and fall,” she says.

Another problem is taste, which can be an issue if there’s too much soda or insufficiently mixed baking powder, says Harold McGee in “On Food and Cooking.” The result? “A bitter, soapy, or ‘chemical’ flavor.”

A good rule of thumb, according to Corriher, is that 1 cup of flour can be leavened by ¼ teaspoon baking soda or 1 to 1¼ teaspoons of baking powder. Corriher says you can neutralize 1 cup mildly acidic ingredient (sour cream, buttermilk) with ½ teaspoon of soda. That same amount of soda will neutralize 1 teaspoon of lemon juice or 1¼ teaspoons of cream of tartar, McGee says.

If you have a very heavy batter loaded with chopped dried fruit or nuts, you can try bumping up the leavening by 20 percent, Corriher says. If you’re changing the pan size in a recipe, from a deeper pan, such as a tube or Bundt, to something shallower, you’ll probably want to drop the leavener, too. And if you live at a high altitude, reducing it (and making other adjustments) is almost a given.

For every teaspoon of baking powder, suggests the Colorado State University Extension, reduce by ⅛ teaspoon at 3,500 to 6,500 feet; ⅛ to ¼ teaspoon at 6,500 to 8,500 feet; and ¼ teaspoon at 8,500 to 10,000 feet.

Another option at a higher altitude, King Arthur Baking says, is to aim for a less vigorous reaction, by using milk and baking powder, for instance, instead of buttermilk and baking soda (more on this kind of swap below).

Are they interchangeable? In a word, no. Because baking soda needs an acid with which to react and baking powder already contains it, they can’t be used in place of each other, at least not without making other adjustments to the recipe. One of the most illustrative examples of the difference has to do with cocoa powder. Natural cocoa is inherently acidic, so baking soda will work well with it. Dutch-process cocoa powder, though, has been treated to reduce its acidity, or alkalized, meaning there’s nothing for the soda to react with, which is why baking powder is typically needed in recipes using it.

Baking powder and soda don’t have equal potency when compared by equal volumes, given the other ingredients added to the powder. As detailed above, you need four times as much baking powder to generate the same lift as baking soda.

That being said, there are ways to swap. If you’re out of baking powder, Corriher recommends mixing a batch of 1 tablespoon baking soda, 2 tablespoons cream of tartar and 1½ tablespoons cornstarch. Because of the fast-acting cream of tartar, this won’t be the same as double-acting baking powder, so be sure to work quickly.

You can also get around the substitution issue by adjusting the acidity of your other ingredients and the amount of the leavener, says Lauren Chattman in “The Baking Answer Book.”

Biscuits are one scenario. “If your recipe calls for 2 teaspoons of baking powder and ¾ cup of milk, you can adapt it by using ½ teaspoon baking soda and ¾ cup of buttermilk,” Chattman says. Need to use natural cocoa powder instead of Dutch process? “Replace the baking powder with one-quarter the amount of baking soda for an equivalent result.”

Why recipes might call for both. In recipes that call for both baking powder and soda, the powder is generally doing the heavy lifting, so to speak. The baking soda is there to help neutralize additional acid in the dough or batter to avoid interfering with the self-contained reaction created by the powder, says Chattman.

The baking soda has an additional benefit. Corriher notes that foods that are too acidic won’t brown well. That browning generated by the Maillard reaction, in which sugars and proteins interact to create new flavor and aroma compounds, is what helps baked goods taste great. Cookie recipes especially take advantage of this baking soda asset. Another point worth noting: Cookies relying on baking soda will spread more because the ingredient neutralizes the acidity that would otherwise cause them to set faster.

Storing. Keep both baking powder and baking soda sealed tightly, away from heat and humidity. I prefer canisters to boxes, and even if I purchase a box of baking soda, I typically transfer it to a canister I already have or another airtight container. The USDA’s FoodKeeper App says opened baking powder will last three to six months in the pantry after opening, baking soda six months. Keep in mind that using old leaveners can really ruin your baked goods. To test the viability, Corriher recommends mixing ¼ teaspoon baking powder into ½ cup very hot water or ¼ teaspoon baking soda into ½ cup very hot water mixed with ¼ teaspoon white vinegar. If you see fine bubbles, you’re good to go.