There are thirty standard levels in Lego Batman: The Videogame.
The main campaign is split evenly between fifteen hero levels and fifteen villain levels. The hero chapters follow Batman and his allies as they stop Gotham’s criminals, while the villain chapters let players experience the criminals’ schemes from the other side.
The game organizes those levels into six chapters, with five levels per chapter. Completing a hero chapter unlocks its corresponding villain chapter, so the two campaigns are designed to complement each other rather than function as entirely separate stories.
A common source of confusion is that the game also contains two secret bonus levels: one set in Wayne Manor and one in Arkham Asylum. Those extras do not change the standard campaign total, which remains thirty levels.