🧩 Maze Generator

Generate random mazes with adjustable size and difficulty. Download as PNG or print directly — all in your browser.

About the Maze Generator

This tool generates random mazes using the depth-first search (DFS) algorithm with recursive backtracking. Each cell starts with four walls, and the algorithm carves passages by knocking down walls between visited cells. The result is a perfect maze — exactly one path between any two cells, no loops, no isolated areas.

Difficulty levels

  • Easy — Additional walls are removed to create multiple paths, making the maze more forgiving.
  • Normal — A standard perfect maze with a single solution path.
  • Hard — A perfect maze biased toward longer corridors and more dead ends.

How to use

  1. Set the number of columns and rows (5–50).
  2. Pick a difficulty level.
  3. Optionally choose to show the solution path in red.
  4. Click Generate, then Download PNG or Print.

Frequently asked questions

What algorithm is used? Depth-first search with recursive backtracking produces a perfect maze. For "Easy" mode, extra walls are removed to add loops.

How big can the maze be? Up to 50×50 cells. Larger mazes take longer to render and print on multiple pages.

Is the solution unique? In Normal and Hard modes (perfect mazes), yes — exactly one path connects the entrance to the exit.