Skip to content
ToolZone

Maze Generator

Generate a random maze at any grid size, then export it as a printable PDF with a solution page showing the correct path.

Runs in your browser. Nothing you enter or upload leaves your device.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the Maze Generator

The Maze Generator draws a new random maze at whatever width and height you choose, from a quick 5x5 for preschoolers to a dense 40x40 for older kids and adults. The route runs from the top-left corner to the bottom-right corner, and you can show the solution on screen or print it on a second PDF page.

How it works

The tool starts with a grid where every cell has all four walls. It uses a randomized depth-first search, often called the recursive backtracker: beginning at the top-left cell, it moves to a random unvisited neighbor and knocks down the wall between them, then repeats. When it reaches a dead end with no unvisited neighbors, it backs up along its trail until it finds a cell that still has one. This continues until every cell has been visited.

The result is a perfect maze: every cell is reachable and there is exactly one path between any two cells, with no loops. That's why there is always one correct route. The solution is found with a breadth-first search from the top-left cell to the bottom-right cell, and it is drawn as a line through the centers of the cells along the way. Depth-first carving tends to produce long, winding corridors with relatively few short dead ends.

How to use

  1. 1

    Enter the Width (cells) and Height (cells), each between 5 and 40; the size is kept in the page link.

  2. 2

    Click New maze until you get a layout you like; the page link then reproduces that exact maze.

  3. 3

    Click Show solution to check the route from top-left to bottom-right, and Hide solution to hide it again.

  4. 4

    Click Download maze + solution as PDF to print the puzzle and its answer.

Worked examples

Preschool maze

A 4-year-old's first maze.

Input
Width 5, Height 5
Result
A 25-cell maze with wide corridors that takes a minute or two

Classroom activity

A second-grade early-finisher sheet.

Input
Width 15, Height 15
Result
A 225-cell maze, the default size

Landscape challenge

A wide maze for older kids.

Input
Width 40, Height 25
Result
A 1,000-cell rectangular maze scaled to fit the page width
Limitations
Start and finish are always the top-left and bottom-right cells, and no entrance or exit gaps are drawn in the outer wall. Mazes are rectangular grids only; circular, hexagonal, or picture-shaped mazes are not available. Each PDF contains one maze and its solution, with a fixed "Maze" title.
Assumptions
Paths run between adjacent cells horizontally and vertically, never diagonally.
Privacy
Mazes are generated in your browser; nothing is uploaded or stored.

Frequently asked questions

Is every generated maze guaranteed to be solvable?+

Yes. The generation algorithm visits every cell and carves a connected network with no loops, so there's always exactly one route from the start to the finish.

What's the largest maze size I can generate?+

Width and height are each capped at 40 cells, which keeps both the on-screen preview and the printed PDF readable.

Where are the start and finish?+

The route starts in the top-left cell and ends in the bottom-right cell. Click Show solution to see it. The outer wall has no gaps, so it helps to mark both corners on the printout.

Can I make a rectangular maze?+

Yes. Width and height are set separately, so you can make wide, tall, or square mazes anywhere from 5 to 40 cells per side.

What is a perfect maze?+

A maze with no loops and no isolated areas, where exactly one path connects any two points. All mazes from this tool are perfect mazes.

Related tools