Prep the pan. Line an 8-inch square baking pan with parchment, leaving overhang for easy lifting.
Lightly butter the parchment so the fudge releases cleanly.
Combine dry and wet. In a heavy saucepan, whisk together sugar, cocoa powder, and salt. Add milk, corn syrup (if using), and butter. Stir gently to combine before turning on the heat.
This helps the sugar dissolve evenly.
Cook without rushing. Set the pan over medium heat. Stir slowly until the mixture looks uniform and the sugar dissolves. Once it starts to bubble, stop stirring to avoid encouraging sugar crystals.
Use a damp pastry brush to wash down any sugar on the sides of the pan.
Reach soft-ball stage. Clip on a candy thermometer and cook to 236–238°F (113–114°C). Don’t guess here—temperature matters. If you don’t have a thermometer, drop a little syrup into cold water; it should form a soft, pliable ball that flattens when pressed.
Cool undisturbed. Remove from heat.
Add vanilla but do not stir. Leave the pan alone until the mixture cools to about 110°F (43°C), or until the bottom of the pan feels just warm and a skin starts to form on top. This takes 20–30 minutes.
Beat to set the texture. With a wooden spoon or sturdy spatula, beat the fudge steadily.
It will go from glossy to thick and matte within 5–10 minutes. This is your sweet spot for that fine, creamy grain. If adding nuts, fold them in right as the gloss disappears.
Spread and smooth. Scrape the fudge into the prepared pan and press it evenly with an offset spatula.
Work quickly; it firms fast. If you like, sprinkle a pinch of flaky sea salt on top.
Let it set. Allow the fudge to cool at room temperature until firm, about 2–3 hours. Avoid the fridge during this stage; fast chilling can affect texture.
Cut and enjoy. Lift the parchment out, cut into small squares with a sharp knife, and wipe the blade between cuts for clean edges.