Place sugar, flour, and cocoa powder into a bowl. Whisk together to remove lumps.
Heat milk, butter, and vanilla extract in a saucepan over medium heat until butter melts.
Whisk dry ingredients into the milk mixture a little at a time. Increase heat to medium-high until mixture comes to a simmer. Cook, stirring constantly, for 6 minutes. After 6 minutes, turn off heat. Whisk in a pinch of salt.
Pour hot over ice cream or store in airtight containers in the refrigerator.