Maze Generator (SVG)
Generate a random perfect maze as a scalable SVG. Choose Recursive Backtracker, Prim's or Kruskal's, set the grid size, cell size, wall thickness and colours, add a solution path, and reproduce any maze from a seed.
Input
Backtracker carves long winding corridors; Prim's grows short branchy dead-ends; Kruskal's gives a uniform, balanced texture.
Same seed + same options = the same maze every time. Leave it blank for a fresh random maze.
Appearance
Output
Your maze will appear here.
Guides
Generate a random perfect maze — one path between any two cells, no loops, no isolated rooms — and get it back as a clean, scalable SVG. Pick a carving algorithm, set the grid and cell size, choose your colours, and optionally overlay the solution. Because the output is vector, it stays razor-sharp at any size: drop it into a worksheet, a game level, a print-ready puzzle, or a web page.
How to use it
- Choose an algorithm (see the differences below).
- Set Columns and Rows (5–80 each) for the grid.
- Tune the appearance: cell size, wall thickness, wall colour, and background.
- Optionally turn on Show solution path and Mark entrance & exit.
- Leave Seed empty for a fresh random maze each time you generate, or type any word or number to lock in a maze you can reproduce exactly later.
- Copy the SVG source or download it as
maze.svg.
The three algorithms and how they "feel"
All three produce a valid perfect maze, but each carves with a different personality — the texture of the corridors is genuinely different.
Recursive Backtracker (a stack-based depth-first search) drills as far as it can before backing up. The result is long, twisty corridors with relatively few but long dead-ends. It feels the most "hand-drawn" and is usually the hardest to solve by eye, because the correct path winds a long way.
Prim's grows the maze outward from a single cell, repeatedly attaching a random frontier cell to the part already carved. This scatters junctions evenly and yields a branchy, organic maze with many short dead-ends — a bushy texture that tends to be easier to scan than the backtracker's long snakes.
Kruskal's treats every wall as an edge, shuffles them all, and knocks down a wall only when it joins two still-separate regions (tracked with a union-find). Because edges are chosen uniformly at random across the whole grid, the texture is uniform and balanced — no directional bias, a very "even" look with a moderate number of medium-length dead-ends.
If you want a punishing puzzle, reach for the backtracker; for a friendlier, more open feel, try Prim's or Kruskal's.
Reproducible mazes with seeds
The generator is driven by a seeded pseudo-random number generator. The same seed plus the same options always produces the exact same maze, on any device — so you can share a seed instead of a file, regenerate a print later, or build a set of puzzles with stable identifiers. Change any option (algorithm, size, even a colour is cosmetic but the seed governs the layout) and the seed still pins the carving. Leave the seed blank and each run draws a brand-new random maze.
Entrance, exit, and the solution
The entrance is the top-left cell and the exit is the bottom-right cell; enabling Mark entrance & exit opens those two outer walls and adds arrow markers. Show solution path overlays the unique shortest route from entrance to exit (found with a breadth-first search) as a coloured line, handy for answer keys.
Is my data sent anywhere?
No. The maze is generated entirely in your browser — nothing you type is uploaded. The SVG you see is the SVG you copy.