Preheat the oven to 375°F (190°C). Line a 10x15-inch jelly roll pan with parchment paper.
In a medium bowl, whisk together the flour, baking powder, baking soda, and salt.
In a large bowl, use an electric mixer to beat the sugar and butter until light and fluffy.
Beat in the eggs one at a time, followed by the vanilla extract.
With the mixer on low speed, gradually add the flour mixture to the wet ingredients and mix until just combined
Stir in the grated carrots and chopped walnuts (if using).
Pour the batter into the prepared pan and smooth the top.
Bake for 12-15 minutes, or until a toothpick inserted into the center of the cake comes out clean.
Remove the cake from the oven and let it cool in the pan for 5 minutes.
Transfer the cake to a wire rack to cool completely.