Skip to content
AZ Tools

Maze Generator (SVG / PNG)

Generate printable mazes with adjustable size, cell scale, and reproducible seed — recursive-backtracking algorithm with optional solution overlay.

How to use

  1. Set the grid width and height (4-60) and the cell size in pixels.
  2. Pick a seed manually or click 'New seed' for a fresh maze.
  3. Toggle 'Show solution' to verify difficulty, then download as SVG (vector) or PNG (2× rasterized for printing).

About this tool

Show

Pick a grid size (up to 60×60), cell pixel size, and a numeric seed. The tool runs a recursive-backtracking depth-first search to carve a perfect maze (exactly one path between any two cells) and renders it as SVG. Start cell is green, end cell is red. Toggle the solution overlay to see the BFS-shortest path drawn in blue, and download as a sharp SVG or a 2× PNG for printing on a worksheet, party game card, or escape-room handout.

A perfect maze has no loops and no unreachable cells, which is another way of saying it is a spanning tree of the grid. That guarantees exactly one route between any two points, so the shortest path and the only path are the same thing and the solution overlay is not choosing between candidates. It also means the classic wall-following trick always works: keep one hand on the same wall and you will reach the exit, because there is no loop to walk around forever.

The algorithm leaves a signature you can see once you know it. Recursive backtracking carves as far as it can before retreating, so it produces long winding corridors and few junctions, which reads as difficult to a person and is quick for a solver. Prim's and Kruskal's algorithms on the same grid give short branches and many dead ends, a maze that looks busier and is usually easier. Difficulty here comes from corridor length rather than from the number of choices.

The seed makes a maze reproducible, which is what you want for a worksheet you will print twice or an answer key generated separately. The same seed and the same grid size always give the same maze; change either and you get an unrelated one.

SVG is the format to download for print because the walls stay crisp at any size. The 2× PNG is for a context that cannot take vector, and at small cell sizes its walls will soften where the SVG would not.

Frequently asked questions

What is a 'perfect maze'?

A maze with exactly one path between any pair of cells — no loops, no isolated regions. Recursive-backtracking always produces a perfect maze and tends to create long, winding corridors with relatively few branches, which feels harder for kids than other algorithms (Prim's, Kruskal's, Wilson's).

Why use a seed?

The same seed + same size always produces the same maze. Lets you share a specific maze with someone (the seed is in the filename), reprint it later, or A/B compare difficulty.

Why does the solution look fairly direct?

Recursive-backtracking biases toward long corridors. The shortest path will be relatively direct compared to other algorithms — but the dead-ends are plentiful, which is what makes solving without the overlay tricky.

Can I get a circular or hexagonal maze?

Not from this tool — only rectangular grids. Circular and hexagonal mazes need different topologies and rendering, which would be a separate tool.

Related tools