In a medium saucepan, whisk together the granulated sugar and cornstarch to form the base of your custard.
Pour in the whole milk gradually, whisking continuously to prevent lumps from forming.
Place the saucepan over medium heat, stirring consistently until it begins to thicken, about 5 to 7 minutes.
In a separate bowl, lightly beat the egg yolks. Slowly add a few tablespoons of the hot mixture to the yolks while whisking constantly to temper them.
Pour the tempered egg yolk mixture back into the saucepan. Continue to cook, stirring constantly, until the custard is thick enough to coat the back of a spoon.
Remove the saucepan from the heat and stir in the vanilla extract and butter until fully incorporated.
Transfer the custard to a heatproof bowl, cover with plastic wrap, and refrigerate until set, about 2 to 3 hours.