Margarine is a very common spreadable nowadays; there are even many recipes that suggest using it over butter. Let's say you want to bake something that requires margarine. However, when performing your mise en place (which is the fancy French term for organizing your ingredients), you realize that there is only butter in your fridge. Or, perhaps you have margarine, but you prefer the taste of butter and want to try doing something with it instead.
Either way, there's the all-important question:
Can you substitute margarine for butter in baking recipes?
The short answer: Of course!
You don't have to run to your nearest grocery store for margarine. They can substitute each other in most recipes, but different factors will help you decide if you should use one or the other when baking.
Can You Use Butter Instead of Margarine in Baking?
You can successfully use butter instead of margarine in most baking recipes. The higher fat content of butter keeps the sponge tender and moist while also giving it a delicious buttery flavor that you won't get when using margarine. For vegan recipes, use margarine instead of butter.
In most baking recipes, butter was the "original" ingredient anyway. However, since the invention of margarine, bakers started using it in many dishes because of its particular properties. It is more stable at room temperature, and it resists heat better, which could make it a better option for heat-resistant creams and fluffier cakes.
Still, doing the swap is easy, and it could become your special touch in the kitchen!
Here is what to expect when doing the swap:
- Recipes with butter will be moister and more tender.
- Some baked products like cakes and cookies could be less fluffy and flatter cookies.
- Your baking products will brown faster.
- As butter has a shorter shelf life than margarine, then the baked products will last accordingly.
So, What Is So Different About Butter And Margarine?
These are so similar that, sometimes, one is marketed as the other. Nevertheless, they are very different ingredients.
Butter is well-known and appreciated, even from ancient times, as a versatile product from churning milk. It can come from the milk of different animal species, although butter made from cow milk is the most common.
Taste can also vary, according to its production process and its composition: We can find variants such as low-fat, salted or unsalted, even with garlic or rosemary!
The low-fat version that has half the fat content of the conventional butter comes from adding gelling agents, aroma, and colorings to make it look like the real thing.
Margarine was invented in 1869, when H. Mege Mouries patented a process to obtain a spreadable from beef fat as a cheap substitute for butter. Its name comes from its margaric acid content, which people believed was the main substance in beef fat. 
Nowadays, its production is quite different. It’s mainly made from vegetable oils that go through industrial processes to obtain solid fat from a liquid (e.g., from seed oil like sunflower, safflower, cottonseed, soybean, rapeseed, or olive oil).
You will also find different types of margarine:
- Soft vegetable fat spreads. This is the most popular one.
- Bottled liquid margarine for cooking and/or top dishes.
- Hard margarine. Mostly used for baking.
Spreadable tub margarine or liquid ones are made with less hydrogenated, i.e., more fluid, oils than the hard block margarine.
Here Are Some Main Differences
The most notable difference between margarine and butter is that the former is made from plant oils and is heavily processed. In contrast, butter is derived from dairy and is rich in cholesterol and saturated fats. Most margarines are vegan and lactose-free, whereas butter is not.
Butter is, of course, made from animal milk, whereas margarine is composed mainly of refined vegetable oil and water.
Butter is made by churning milk or cream to separate the fats from the liquid. The small lumps of fat are then compressed together to form the familiar yellow block.
The manufacturing of margarine is more of a chemical process, where a blend of oils and fats are emulsified to create a spread.
Butter is a good source of vitamin A and contains a bit of lactose. Meanwhile, margarine is a good source of sodium and vitamin E and is usually a good choice for vegans.
Both of them contain around the same number of calories.
The two are roughly similar in fat content, so they are both equally fattening. Margarine is slightly less calorific, with around 60% fat content. But there is also butter on the market with a reduced fat content (some brands sell it with 50% fat). However, Butter contains high levels of saturated fats, whereas margarine contains not only saturated fats but also unsaturated and trans fats.
As for which is the healthier option, that depends on the individual. Both contain saturated fats that raise LDL cholesterol, which is bad for your arteries.
Hydrogenated margarine contains high levels of trans fats that are bad news for your heart. However, non-hydrogenated margarine contains no trans fat, and it is softer than the hard margarine stick often used for baking. 
There is no 100% healthful option when it comes to these two spreads. So, it's best to use either in moderation.
Which you prefer is, of course, a subjective choice, but butter is generally considered a better, tastier option for baking. The main difference in taste comes down to fat content. Whereas margarine consists mainly of oils, butter also contains proteins and other elements that add to its flavor. Many people think butter has a more "natural" taste, but it is all down to your personal preference.
Once again, the texture difference comes down to their relative fattiness, oiliness, and how they are possessed.
Butter feels more solid at room temperature and can be challenging to spread straight from the fridge. Margarine, on the other hand, is ready to spread as soon as you take it out of the refrigerator. (Except the hard stick one). Which texture you prefer will come down to personal taste.
Margarine is not quite there yet when it comes to the buttery taste of its dairy counterpart, but it is getting closer. Besides, the flavor depends on which vegetable oil was used to make it. Margarine variants made with corn and sunflower oil have a milder taste compared to those made with soy oil.
When it comes to texture, recipes with butter will be moister and more compact, while margarine will give a drier result with more air pockets, which is common to see in bread and cakes.
The production of margarine requires more chemical processes to achieve consistency, which gives it a long shelf life. Butter, on the other hand, does not need heavy processing and usually has fewer preservatives; therefore, its shelf life (and the shelf life of the goods made with it) is shorter.
Practical Tips For Swapping These Ingredients
- Butter and margarine are easily convertible when it comes to cooking measures. Since they weigh practically the same, you can exchange 1 cup of margarine to 1 cup of butter.
- Use it preferably cold. When using butter in a baking recipe, let it sit in the fridge for 15-30 minutes, as most recipes will rely on how solid it is at the time of mixing it with other ingredients.
- If you want your cookies and cakes to be a bit drier and more solid, adding one teaspoon of cream of tartar (or corn starch, if you can't find the cream of tartar) should work.
Are They Irreplaceable in Any Recipe?
Yes. Butter is the star of recipes like butter-cookies and butter-cake. These are still doable with margarine, but the final result will be different: They will lose their aroma and that "homemade" taste people know and love.
Butter is also a solid choice for puff pastry, giving it the flavor and elasticity that most kinds of margarine and spreads cannot achieve.
Margarine, of course, has its perks as well. For example, in recipes that require shortening, it makes a better substitute than butter because of its consistency, mild flavor, and better heat resistance.