Flag Cake
- By Jennifer Segal
- Updated July 3, 2025
- 62 Comments
- Leave a Review
This post may contain affiliate links. Read my full disclosure policy.
Red, white, and yum—this berry-topped flag cake is just the thing to bring to your Fourth of July get-together.

A soft yellow cake topped with luscious cream cheese frosting and fresh berries, this festive flag cake is the ultimate July 4th dessert. I know that decorating cakes can be intimidating, especially for non-bakers, but this one is quick and easy—promise!
Before we get to the step-by-step, I have to give credit where it’s due. The cake portion of this recipe comes from my all-time favorite cake cookbook, Perfect Cakes by Nick Malgieri. Decorating inspiration comes from Gaby Dalkin of What’s Gaby Cooking, whose easy method for creating the stars and stripes I copied. Instead of using a frosting-filled pastry bag fitted with a star tip to make the white portions of the flag design, she coats half of the berries in powdered sugar. This makes decorating the cake doable for everyone, even young kids.
What You’ll Need To Make A Flag Cake

The ingredients for this flag cake are pretty straightforward. My only advice is to get the prettiest, firmest berries you can find. It will make decorating the cake much easier. Also, if you don’t want to purchase an entire carton of buttermilk for this recipe, see my post on how to make buttermilk using milk and vinegar or lemon juice.
Step-by-Step Instructions
Step 1: Mix the dry ingredients. In a medium bowl, whisk together the flour, salt and baking soda and set aside.

Step 2: Cream the butter and sugar. In the bowl of an electric mixer fitted with the paddle attachment (or beaters), beat the butter and sugar on medium speed until light and fluffy, about 5 minutes. Then mix in the vanilla.

Step 2: Add the eggs. Beat in the eggs, one at a time, scraping down the sides of the bowl as necessary. Don’t worry if the batter looks a little curdled at this point.

Step 3: Add the dry ingredients and buttermilk. With the mixer on low speed, add one-third of the flour mixture. Then pour in half of the buttermilk and mix just until combined. Scrape down the sides and bottom of the bowl, then add another third of the flour, followed by the rest of the buttermilk. Finish with the remaining flour and mix just until everything is evenly combined.

Step 4: Fill the pan. Scrape the batter into the prepared baking pan and use a rubber spatula to even out the top.

Step 5: Bake. Bake for about 30 minutes, until the cake is set and lightly golden around the edges, and a toothpick inserted into the center comes out clean. Set the cake on a wire rack to cool completely.

Step 6: Make the Frosting. In a stand mixer with the paddle attachment (or a large bowl with a hand mixer), beat the cream cheese, butter, vanilla, and salt on low until combined, then on medium-high until light and fluffy—about 2 minutes. Gradually mix in 4 cups of confectioners’ sugar on low, then beat again on medium-high until fluffy, about 1 more minute. Set aside 1 tablespoon of frosting for the blueberry “stars.”

Step 7: Frost and decorate. Spread the frosting evenly over the top with an offset spatula. Don’t worry about making it perfect—it won’t show. Use a toothpick to outline the stars section in the upper left corner (or just eyeball it), then fill it in with a generous layer of blueberries. For the stripes, lay one row of raspberries across the top, sideways, for the first red stripe. Roll the next row of raspberries in confectioners’ sugar for a white stripe, and keep alternating until the flag is complete.

Dip a small handful of the remaining blueberries in the reserved frosting, then roll them in the remaining confectioners’ sugar to make white “stars.” Scatter them evenly over the blueberry section of the flag. Serve the cake right from the pan. It’s best enjoyed the day you make it—or the day after at the latest.

More July 4th Desserts You May Like
Flag Cake
A soft yellow cake topped with cream cheese frosting and fresh berries, this flag cake is the perfect patriotic dessert for a crowd.
Ingredients
For the Cake
- 2¾ cups all-purpose flour, spooned into measuring cup and leveled-off
- ½ teaspoon salt
- ½ teaspoon baking soda
- 2 sticks (1 cup) unsalted butter, softened
- 2 cups sugar
- 2 teaspoons vanilla extract
- 4 large eggs, at room temperature
- 1 cup buttermilk (see note)
For the Frosting and Topping
- 8 oz cream cheese, at room temperature
- 1 stick (½ cup) unsalted butter, at room temperature
- 1 teaspoon vanilla extract
- Pinch salt
- About 5½ cups confectioners' sugar, divided
- 1 half-pint (6 oz) blueberries (see note)
- 4 half-pints (24 oz) raspberries (see note)
Instructions
For the Cake
- Preheat the oven to 350°F and set an oven rack in the middle position. Butter and flour a 9x13-in metal pan, or use nonstick cooking spray with flour in it, such as Baker's Joy or Pam with Flour.
- In a medium bowl, whisk together the flour, salt and baking soda. Set aside.
- In the bowl of an electric mixer fitted with the paddle attachment (or beaters), beat the butter and sugar on medium speed until light and fluffy, about 5 minutes. Beat in the vanilla, then beat in the eggs, one at a time, scraping down the sides of the bowl as necessary. (Don't worry if the batter looks a little curdled at this point.)
- Reduce the speed to low, then beat in one-third of the flour mixture, followed by half of the buttermilk. Scrape down the sides and bottom of the bowl, then add another third of the flour, followed by the remaining buttermilk. Beat in the remaining flour, then scrape down the bowl and beat again until the batter is evenly combined. Do not overmix.
- Scrape the batter into the prepared baking pan and bake for 30 to 35 minutes, until the cake is set and lightly golden around the edges, and a toothpick inserted into the center comes out clean. Set the cake on a wire rack to cool completely.
For the Frosting and Topping
- In the bowl of a stand mixer fitted with the paddle attachment (or large bowl if using a hand mixer), combine the cream cheese, butter, vanilla and salt. Mix on low speed until combined, then increase the speed to medium-high and beat until aerated and light, about 2 minutes. Gradually add 4 cups of the confectioners' sugar, mixing on low speed to combine. Once the confectioners' sugar is mixed in, increase the speed to medium-high and beat until fluffy, about 1 minute. Set aside 1 tablespoon of the frosting (you'll need it for the blueberry "stars.")
- When the cake is completely cool, use an offset spatula to spread the frosting evenly over top. The frosting won't show so no need to fuss over making it perfect.
- Outline the "stars" section on the upper left corner of the cake with a toothpick (or skip this step and just eyeball it) and fill with a generous layer of blueberries. Dip a small handful of the remaining blueberries in the reserved frosting, and then in the remaining 1½ cups of confectioners' sugar to make white "stars." Evenly scatter the "stars" over the section of blueberries. Arrange 1 row of raspberries across the top of the cake, laying them sideways, like a red stripe. Gently roll the next row of raspberries in the confectioners' sugar to make a white stripe, and alternate until the flag is completed. (I suggest using one hand for rolling and one for placing; if any powdered sugar accidentally gets on the red "stripes," use your fingertip to dab the berries lightly with water and it will come right off. )
- Cut the cake into squares and serve directly from the pan.
- Note: If you’d like to make your own buttermilk, check out the easy method here.
- Note: The berries should be dry before decorating the cake. (In general, I don't rinse raspberries because they are so delicate.)
- Make-Ahead Instructions: The cake itself can be made one day ahead of time. Cover with plastic wrap and store at room temperature. Frost and decorate the cake before serving.
Nutrition Information
Powered by ![]()
- Per serving (24 servings)
- Serving size: 1 piece
- Calories: 393
- Fat: 16 g
- Saturated fat: 9 g
- Carbohydrates: 60 g
- Sugar: 46 g
- Fiber: 2 g
- Protein: 4 g
- Sodium: 143 mg
- Cholesterol: 72 mg
This website is written and produced for informational purposes only. I am not a certified nutritionist and the nutritional data on this site has not been evaluated or approved by a nutritionist or the Food and Drug Administration. Nutritional information is offered as a courtesy and should not be construed as a guarantee. The data is calculated through an online nutritional calculator, Edamam.com. Although I do my best to provide accurate nutritional information, these figures should be considered estimates only. Varying factors such as product types or brands purchased, natural fluctuations in fresh produce, and the way ingredients are processed change the effective nutritional information in any given recipe. Furthermore, different online calculators provide different results depending on their own nutrition fact sources and algorithms. To obtain the most accurate nutritional information in a given recipe, you should calculate the nutritional information with the actual ingredients used in your recipe, using your preferred nutrition calculator.
See more recipes:
Comments
Add a Comment Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.



My friend has a July 4th party every single year where everything (and I mean everything) has a flag on it or it’s something patriotic. At the very least, the items are red, white, or blue.
I normally bring very boring and predictable (safe!) side dishes to her party but this year, after seeing this cake in my inbox, I decided to go for it. I haven’t baked in a long time and why not start with a cake I’ve never made before and serve it to strangers?? What could possibly go wrong?
Because Jenn’s recipes always turn out, I felt slightly more comfortable than if I were using someone else’s site. And like I predicted, the cake turned out fantastic! I received rave reviews from everyone, and even the professional photographer at the party wanted a picture of me with the cake because she knew it was something that the host would adore.
Two things I learned from making this fabulous flag cake recipe is that I will never again pay $60 for a birthday cake–everyone is getting something homemade from a recipe from this wonderful website. And blueberries dipped in freshly made cream cheese frosting and covered in confectioner’s sugar taste WAY better than plain.
Thank you, Jenn!
I only wish I could upload a photo!
Yay! So happy it turned out well, Catherine. I wish there was a way to upload a photo. You can always email it to me directly…I’d love to see!
Thanks for this recipe! I had a delightful four year old as a guest for the Fourth and she helped place the berries on top. When we asked how she wanted to celebrate her birthday which is coming up soon, she said, “I want to make a flag cake!”
Fantastic cake! Sweet, but not too sweet with a yummy frosting and fresh berries. What’s not to love? I made this for 4th of July and it was a great hit. Awesome!
Hi Jenn,
I made the cake today using Cup-4-Cup gluten free flour and followed everything else to a tee. The cake got rave reviews! Note that the raspberries dipped in powdered sugar did not maintain their whiteness after a few minutes, but they were light enough that you could distinguish the different stripes of the “flag.”
Thanks for another great recipe!
Happy 4th to you Jen ,
Can I make this today or should I just bake this today and frost and assemble fruit tomorrow before the party? Thanks for this wonderful recipe!
Hi Sandra, You can bake, frost, and decorate it today – it keeps well as long as the berries are dry. Enjoy!
Hi Jenn, how long do you usually leave the butter and cream cheese and egg out to achieve “softness/room temp?”
Can’t wait to make this tomorrow!
Hi Crissy, My kitchen is very sunny so 1 to 2 hours is usually enough. If your kitchen is cool, it may take a little longer. Hope that helps!
Hi Jenn,
Is the 9 X 13 pan a 1″ or 2″ depth? I was thinking of adding a layer of peaches in the middle and rather than slicing the cake into 2 layers, I was going to use 2 pans that are 1″ depth. What do you think?
Thanks!
Hi Jaimee, My pan is 2 inches deep; I think your plan should work. I’d love to know how it turns out!
Could this be made in a bigger pan? 12 by 15??? If so should I do 1 1/2 recipes? Thanks so much! Feeding a lot of people. Happy 4th!
Hi Janet, Sure…and yes, if you increase the recipe by 1.5, I’d use a half sheet pan.
Hi Jen,
Can you half the recipe? If yes, how much flour do you need?
Thanks,
Janelle
Sure– technically it will work but you’ll have a square flag instead of a rectangular one. 🙂 You can halve all the ingredients and bake it in an 8 x 8“ pan (baking time may be a bit shorter so keep a close eye on it). Enjoy!
My son’s birthday falls around July 4th, and this is the cake he picked for his party this year. Luckily, the cake baked just fine for me, set in the center at about 35 mins. The decorating was easy and turned out so cute! If I was feeling ambitious, I would maybe bake the batter in two layers with some frosting in the middle, just to even out the cake-frosting ratio of each bite. The flavor of both the cake and frosting were delicious, and the fruit was a nice balance to the sweetness of the rest of the cake. Will definitely make again for our next patriotic party!
Could you make this into cupcakes? I understand you would be able to make the flag design but could you just put the berries on top?
Hi Jennifer, Definitely – cook time will be 20 to 25 min. Enjoy!