What makes a cheese melt
Cheese melts when heat loosens the protein network and the fat can flow. Moisture gives the cheese something to flow with. A young, moist cheese usually melts. A very dry, long-aged cheese softens and then leaks fat.
Acid and calcium matter too. A cheese that was set with a lot of acid, or cooked in its whey, keeps a tight protein network. Heat firms that cheese instead of melting it. Age breaks proteins into smaller pieces. Some of that helps a melt. Too much of it, in a very old dry cheese, makes the melt grainy.
You can predict a melt from the label more often than from the color. Look at the age, the texture, and whether the cheese is fresh, stretched, pressed, or brined. The milk matters less than those facts.
Cheeses that melt well
Young pressed cheeses and many stretched-curd cheeses melt. Gruyère, Comté, young Gouda, fontina, Emmental, Jarlsberg, Monterey Jack, Havarti, raclette, and young cheddar are reliable. They have enough moisture to flow, and not so much age that the proteins seize.
Low-moisture mozzarella is the pizza cheese. It stretches and browns. Fresh mozzarella from a tub of liquid will steam, puddle, and release water. Use the fresh one on a salad or a brief bake. Use the low-moisture one when you need a sheet of melted cheese.
Taleggio and other soft washed rinds melt into a rich pool. They are strong. Use them where that smell belongs, or mix a little into a milder melter. A young provolone also melts. An aged provolone is better as a sharp slice.
Cheeses that hold their shape
Paneer, halloumi, queso fresco, and many fresh acid-set cheeses keep their shape in a pan. Paneer is set with acid and pressed. It takes on the sauce around it. Halloumi is heated in whey when it is made, so the proteins are already set. It sears and stays squeaky.
Feta softens and warms. It does not stretch. Queso fresco softens a little and keeps a crumb. These are cheeses for stuffing, grilling, or scattering, not for a cheese sauce.
A long-aged grating cheese such as Parmigiano-Reggiano or Pecorino Romano softens, then turns oily if you ask it to melt alone. Use it as a finish, or grate a little into a sauce that already has a younger cheese. Cotija behaves the same way.
A smoother sauce
Heat the cheese gently. A hard boil makes the fat split from the protein. Grate the cheese first so it melts in one pass. Take the pot off the boil, then add the cheese a handful at a time and stir.
Starch helps the sauce stay together. A thin white sauce, a spoon of the starchy water from pasta, or a little flour in the base gives the cheese a structure to hold. Add salt only after the cheese is in. Many melting cheeses are already salty.
Some cooks add a little sodium citrate, the salt that keeps processed cheese smooth. If you use it, follow the amount sold for cheese sauce. You do not need it for Gruyère or fontina. You may want it for a sharp aged cheddar that wants to split.
In the oven and under a grill
Shred the cheese. A thick cold slab browns on top before the center melts. Cover the dish for part of the bake if the top is sealing into a skin. Uncover it at the end for color.
A hot grill for a minute or two finishes a gratin. A long blast dries the cheese and splits the fat. Leftover cheese on a baked pasta will melt better if you add a spoon of milk or a moist sauce before it goes back in the oven.
A microwave can melt a small portion. Use short bursts and stir between them. A long run will boil the cheese and drive the fat out. It is a tool for a sandwich, not for a sauce you care about.
When the fat splits
An oily surface means the emulsion broke. The cheese was too hot, too dry, or added too fast. Pull the pan off the heat. Whisk in a spoon of cold milk, cream, or starchy pasta water. A small extra grate of a younger, moister cheese can also bring it back.
Do not keep boiling a broken sauce. More heat makes the split worse. If it will not come back, use it as a crumbly topping where the oil is less obvious, and start the next sauce at a lower heat.
Processed cheese melts in an even sheet because emulsifying salts hold the fat and the protein together. A wheel of cheddar has no such salt. Treat them as different products. One is made to melt. The other is a cheese that can melt if you help it.
A blend melts better than one tired cheese
Mix a flavor cheese with a melting cheese. A little Parmigiano-Reggiano in a base of Gruyère or young Gouda tastes deeper and still flows. A little blue in fontina makes a strong sauce without asking the blue to melt alone.
Match the salt. If the flavor cheese is Pecorino Romano or feta, use less of it and taste before you add any salt from the jar. Match the moisture. A spoon of fresh ricotta loosens a stiff melt. It will not brown the way mozzarella does.
The substituting guide lists swaps by the job the cheese does. Use it when the cheese you want is not in the shop. Stay inside the melting job if the dish depends on stretch or a smooth pool.