In a medium saucepan, whisk together the sugar, cocoa powder, cornstarch, and salt.
Gradually pour in the milk while whisking continuously until the mixture is smooth.
In a separate bowl, whisk the egg yolks.
Slowly add a small amount of the warm milk mixture to the egg yolks while whisking constantly.
Pour the egg mixture back into the saucepan and whisk to combine.
Cook over medium heat, whisking continuously, until the mixture thickens and becomes creamy.
Remove the saucepan from the heat.
Add the chopped chocolate, butter, and vanilla extract.
Stir until the chocolate and butter are completely melted and the pudding is smooth.
Pour into individual serving dishes.
Serve warm or cover and refrigerate for 1–2 hours for a chilled dessert.
Add whipped cream, chocolate shavings, fresh berries, or chopped nuts before serving.