What is Maze Generator?

Generate random solvable mazes using depth-first search algorithms. Adjust maze dimensions, wall thickness, and path width. Watch the maze being constructed step-by-step or generate it instantly, then solve it manually or let the algorithm find the path.

Pick a grid between 5×5 and 50×50, or hit one of the Small / Medium / Large / X-Large presets, then choose recursive backtracker for long winding corridors or Prim's for shorter dead-end-heavy paths. Watch the canvas carve the walls cell by cell, play through with arrow keys or swipes, reveal the shortest solution, and export the finished maze as PNG, SVG, or a print-ready PDF. A small stats bar shows the cell count and solution length so you can pick the right difficulty before printing.

How to use

  1. Set the maze dimensions (rows and columns) and choose the generation algorithm (recursive backtracking or randomized Prim's).
  2. Click 'Generate' to create the maze. Optionally enable the animation to watch the algorithm carve paths in real time.
  3. Solve the maze by clicking cells to trace a path, or click 'Show Solution' to reveal the optimal route from start to finish.

When to use

  • Printing a custom maze for a kid's birthday party or a quiet activity book.
  • Designing levels for a tabletop game, escape room, or homemade puzzle book.
  • Demonstrating pathfinding algorithms in a CS class or a programming tutorial.

Result

Generate a 25×25 maze with recursive backtracking, set the start to the top-center and the exit to the bottom-right, then play through with arrow keys. The timer and move counter live in the panel above the maze, and you have three hints to spend if a dead end traps you.

FAQ

What's the difference between recursive backtracker and Prim's algorithm?
Recursive backtracker tends to produce long winding corridors with few branches — feels like a classic maze. Prim's algorithm gives shorter passages and more dead ends, so it feels denser and harder to skim by eye even though both have a unique solution.
Is the maze guaranteed to be solvable?
Yes. Both algorithms produce a perfect maze: exactly one path connects any two cells, with no loops or unreachable areas. The start and exit you pick (any of eight corners or edge midpoints) are always joined by a single optimal route.
How do I play through the maze with the keyboard?
Click 'Play Maze' and a marker appears at your chosen start. Use arrow keys or WASD to step through corridors; the marker stops at walls. A live timer and move counter track your run, and you get three hint reveals if you get stuck. A message confirms the solve when you reach the exit.
Can I print the maze on paper?
Yes. PDF is the easiest path — it lays the maze out on a Letter-sized page with a clean margin, so you can hit print straight away. PNG and SVG also work if you want to drop the maze into a worksheet or design tool first. For best legibility on paper, set a path size of 12-14 px with thin walls before exporting.
Why is the animation slow on a 50×50 maze?
Each step animates one cell carve, so a 2500-cell maze takes a moment. Bump the speed slider to 4 for near-instant generation, or turn the Animate toggle off so the finished maze appears immediately.

Related Tools