How this maze generator works
Every maze here is a perfect maze: the cells are joined so that there is exactly one path between any two of them, with no loops and no closed-off areas. The generator carves the maze, picks a start on the top edge and a finish on the bottom edge, and then finds the single route between them so the answer is always correct.
Two ways to carve a maze
| Style | Algorithm | What you get |
|---|---|---|
| Winding | Recursive backtracker (depth-first search) | Long corridors, few forks, a long correct route |
| Branching | Randomised Prim's algorithm | Many short dead ends and forks, a shorter correct route |
We measured 60 mazes of each preset size. In winding mazes about 10% of the cells were dead ends (for example about 104 of 1,024 cells at 32 × 32); in branching mazes about 32% were (about 327 of 1,024 cells).
Custom sizes and the maze code
- Custom size: choose “Custom size…” in Difficulty and set width and height from 5 to 40. The width and height can differ, so you can make tall or wide mazes.
- Maze code: every maze is built from a short code. Type the same code, size and style and you get the same maze every time. Copy the page address to share it.
- Answers: tick “Show answers” to draw the solution path, or print the answer sheet.
- Export: print to paper or PDF, or download a 300 dpi PNG for a slide, a document or a game board.
For teachers, parents and puzzle makers
The generator is built for printing, but the PNG export is handy for worksheets in a word processor, classroom slides, escape-room props or board-game prototypes. Because a code recreates the same maze, you can keep a teacher copy and a student copy that always match. If you only need a quick page of mazes at standard difficulties, the maze worksheet page has them ready.
FAQ
How does a maze generator work?
It starts with a grid where every cell is walled in and removes walls using an algorithm such as depth-first search or Prim's algorithm, until every cell is connected exactly once. That guarantees one route from start to finish.
What is the largest maze I can make?
40 × 40 cells (1,600 cells). Mazes above 22 cells in either direction are limited to two per page when printing.
Can I make the same maze again?
Yes. The maze code, size and style fully determine the maze. The page address stores them, so a bookmark reopens the same maze.
Is there only one solution?
Yes. These are perfect mazes: exactly one route connects the start and the finish.
What is the difference between winding and branching?
Winding mazes have long corridors and few forks. Branching mazes have many short dead ends. Both have one solution.
Are my mazes or settings uploaded?
No. Mazes are generated in your browser, and nothing you type (such as a worksheet title) is sent to our servers.