Preheat oven to 350°F (175°C). Grease or line an 8x8-inch pan.
In a large bowl, whisk together flour, cocoa powder, baking soda, and salt.
In another bowl, combine sugar, oil, and vanilla extract.
Add grated zucchini to the wet mix and stir until combined.
Fold the dry mix into the wet mix until just incorporated.
Stir in chocolate chips and walnuts, if using.
Spread batter evenly into the prepared pan.
Bake for 30–35 minutes or until a toothpick comes out with moist crumbs.
Let cool in the pan for 20 minutes, then transfer to a wire rack.
Slice and serve once fully cooled.