piapia123
en

Maze Generator

Generators

Everything runs locally in your browser — nothing is uploaded

PreviewChange any option above and this redraws at once
SVG source

Generate a maze and export it as SVG for printing or for use as artwork. Every maze is solvable, and the solution is unique. The generator uses recursive backtracking (depth-first with randomised neighbour choice), which has two mathematical properties: exactly one path between any two cells, and no loops. That is worth stating, because the other common approach — fill everything with walls and knock some down at random — can leave unreachable regions (unsolvable) or create loops (multiple solutions), and both still look like a maze on screen. The randomness is seeded. Every choice in the generation rolls a die; with `Math.random`, asking for the same parameters again gets you a different maze, which rules out printing the same one twice. This uses a seeded pseudo-random generator, so same size plus same seed equals the same maze. It needs no cryptographic strength — it is only a pattern. The entrance is top-left and the exit bottom-right, with those two walls opened; leaving the maze sealed would read as a failed generation. Tick “Draw the solution path” to get the answer as well.

Features

  • Recursive backtracking: the maze is always solvable and the solution unique (no loops, no unreachable areas)
  • Adjustable columns, rows and cell size (from 4×4 up to 80×80)
  • Seeded randomness: the same parameters always produce the same maze, reproducibly
  • Entrance top-left, exit bottom-right, with both walls opened
  • Optional solution path in an adjustable colour
  • Wall and background colours adjustable (light walls on a dark ground work too)
  • Exports SVG: vector, so it prints sharply at any size and drops into a design file
  • Shared walls are drawn once, so no line comes out thicker than its neighbours

How to use

  1. Adjust the columns, rows and cell size, watching the preview
  2. Change the seed for a different maze; note the seed down to reproduce one
  3. Tick “Draw the solution path” when you want the answer
  4. Click Download .svg to take the vector file

FAQ

Is every generated maze solvable?
Always, and the solution is unique. Recursive backtracking builds a spanning tree: opening a wall adds an edge, and the finished maze has exactly n−1 edges connecting n cells. That structure guarantees two things — a path exists between any two cells (so the entrance always reaches the exit), and there are no loops (so there is only one such path). The “fill everything then knock walls down at random” approach cannot promise either, and can leave regions you simply cannot reach, while still looking perfectly normal on screen.
What is the seed for?
Reproduction. Generation rolls many dice, and with true randomness asking for the same parameters again gives a different maze. A seeded generator fixes which roll comes out when, so same size plus same seed equals exactly the same maze. That matters in practice: a child who wants the same maze again, or a wish to make it harder while keeping the same character — just write the seed down. Cryptographic strength is unnecessary; this is a picture, not a key.
Can I print it directly?
Yes. The downloaded SVG is vector, so it stays sharp when enlarged — which is exactly why SVG rather than PNG: the same 20×14 maze as a PNG shows stair-stepping when scaled to A4, while vector lines stay clean. If the printed lines look thin, increasing the cell size helps more than thickening the lines, because the line width is derived from the cell size.

Related tools