In a bowl, whisk together the granulated sugar, egg yolks, cornstarch, and salt until smooth.
Warm the milk in a saucepan until steaming but not boiling.
Slowly whisk a little hot milk into the egg mixture, then pour the tempered egg mixture back into the saucepan.
Cook over medium heat, whisking constantly, until thickened.
Remove from the heat and stir in the butter and vanilla extract.
Transfer the pastry cream to a bowl. Place plastic wrap directly on the surface and chill until cold.