Add cocoa to large bowl and whisk or sift to remove lumps. Add butter and beat until combined.
1 cup unsweetened cocoa powder, ½ cup unsalted butter, softened to room temperature
Add powdered sugar, vanilla, milk, and espresso powder, if using. Beat on low speed until combined; beat on high speed about 2 minutes until fluffy and smooth.
4 cups powdered sugar, 1 teaspoon pure vanilla extract, ½ cup milk, 1 teaspoon espresso powder, optional
If consistency of frosting is too thin, add more powdered sugar, ¼ cup at a time, beating after each addition. If the frosting is too thick, add milk a teaspoon at a time until frosting is desired consistency.
Frosting can be used to frost a sheet cake (see note), layer cake, cupcakes, or brownies. Make sure they are completely cool before frosting.
Video
Notes
Salt: A lot of cooks like to add a pinch of salt to frosting to keep it from being too cloyingly sweet. If you use salted butter, don't add extra salt.
Yield: Makes about 2 ½ cups of frosting, which is enough to frost and fill a 2-layer cake, or to frost 24 cupcakes. Make a half batch for 9 x 13-inch cake unless you like a thick layer of frosting.
Storage: Frosted baked goods can be stored at room temperature for a couple of days. Be sure to cover them. If your kitchen is quite warm, I recommend refrigeration.
Make ahead: Frosting can be made ahead, transferred to an airtight container, and refrigerated for up to one week, or for three months in the freezer. To use, if the frosting is frozen, thaw it overnight in the refrigerator.If frosting has deflated a bit, or it's too stiff, use your mixer to whip it again briefly.
Variations: Instead of vanilla, try maple extract, almond extract, or a berry extract, such as cherry or raspberry, or if you want it boozy, add a teaspoon of rum, bourbon, or brandy. For milk chocolate frosting, use ½ cup cocoa powder, and increase powdered sugar by ½ cup. For Mexican hot chocolate flavor, stir in 1 teaspoon cinnamon and add a pinch of cayenne if you like.