Maze Generator

Generate a printable maze with an easy/medium/hard difficulty, plus a separate answer key page showing the one true solution. Free, private, in-browser.

🌐 Español

Maze settings

🔒 Private by design: everything runs locally in your browser and never uploaded to any server.

What a “perfect maze” is, and why the answer key depends on it

Most disappointing printable mazes fail in one of two ways. Either a region of the grid is walled off entirely, so no route exists, or the puzzle has several equally valid routes, which makes an “official” answer sheet arbitrary. Both failures come from the same source: walls placed at random and then checked afterwards, if at all.

This generator carves instead of placing. Starting from the top-left cell, it walks to a random unvisited neighbour, knocking down the wall between the two, and backtracks whenever it runs out of unvisited neighbours. That is the recursive backtracker, and what it produces is a spanning tree over the grid: every cell reachable, exactly rows * cols - 1 walls removed, no loops anywhere. A tree has one and only one simple path between any two of its nodes, which is why a maze built this way is solvable and has a single solution by construction rather than by inspection.

We did not take that on trust. The tests count the removed passages, run a breadth-first sweep to confirm every cell is reachable, and on small grids exhaustively enumerate every simple path between the two corners, asserting the count is exactly one. There is also a negative control that deliberately opens one extra passage to create a cycle and confirms the path count then climbs above one, so the check is proving something rather than passing vacuously.

Picking a grid size a pencil can actually follow

The difficulty selector is not a different algorithm at each setting, only a bigger grid: Easy is 10x10, Medium is 16x16, Hard is 22x22. Custom lets you set rows and columns separately, each between 5 and 40.

The number worth thinking about is the printed cell size. On A4 the page is 595 by 842 points, and the layout reserves a 40 point margin all round plus a 40 point strip for the title, leaving roughly 515 by 722 points for the grid. Cells are always square, sized by whichever axis is tighter. So a 22x22 hard maze gets cells of about 23 points, near 8 mm, which a pencil handles comfortably. Push Custom to 40x40 and cells fall to roughly 13 points, about 4.5 mm, where a pencil line starts to smear across two corridors and a fine-tip pen is a better idea.

For a class of seven to twelve year olds, Medium is the setting we would pick. Save the 40x40 grids for a wall poster or for someone who genuinely wants a ten minute puzzle.

From preview to printer

  1. Pick a Difficulty, or choose Custom and enter your own Rows and Columns.
  2. Set Paper size to A4 or Letter, matching whatever your printer is loaded with.
  3. Click Generate maze. The maze appears immediately as an SVG preview, sized so that even a 40x40 grid still fits the page column.
  4. Tick Show solution to overlay the route, or click Generate a new maze as many times as you like until you get one you like the look of.
  5. Click Download PDF. The file is built from the exact maze in the preview, so nothing changes between the screen and the page.

What actually lands in the two-page PDF

Page one is titled “Maze” and carries the grid with a break cut into the top-left cell’s outer left wall and another in the bottom-right cell’s outer right wall, labelled START and FINISH in the margin beside each. Those breaks only ever touch a boundary wall, which is why cutting them cannot disturb the connectivity proof above: that proof is only ever about walls between two real cells.

Page two is titled “Answer key” and redraws the identical walls with the unique solution traced through the cell centres as a red line. Same grid geometry, same cell positions, so you can hold the two pages up to the light and they align. The file is named after the grid, for example maze-22x22.pdf, which makes a folder of them easy to sort later. If you are handing the maze out, print page one only and keep page two for yourself.

The whole document is assembled with pdf-lib in the tab you have open, the same library behind our Printable Calendar and Bingo Card Generator. It shares the page-size constants with the rest of the PDF tools, so an A4 maze is the same 595 by 842 points as an A4 page anywhere else on this site.

Rectangular only, and why we did not fake a round one

There is no circular or hexagonal option here, and that is a deliberate omission rather than an oversight. A polar maze is built from concentric rings divided into sectors, where an outer ring usually holds more cells than the ring inside it, so a cell’s neighbour count is not fixed the way it is in a grid. Carving and solving one means writing the whole adjacency model again in ring and sector terms.

The tempting shortcut is to generate a square maze and crop it to a circle. That looks round and is wrong: the passages it shows are the ones a rectangular grid carved, chopped mid-corridor at the circle’s edge. Rather than ship a maze that misrepresents its own structure, we shipped rectangles properly and left polar geometry as a separate, honestly unbuilt feature. If you want something round to hand a small child in the meantime, the Coloring Page Maker is the better tool for that job.

See it in action

Screenshot of the Maze Generator tool with a maze generator with difficulty set by grid size - easy at 10x10, medium at 16x16, hard at 22x22 or custom - laid out for A4 or Letter paper
Maze Generator mid-process: a maze generator with difficulty set by grid size - easy at 10x10, medium at 16x16, hard at 22x22 or custom - laid out for A4 or Letter paper.
Diagram: where the work happens on a SysFenix page that has no file input at all: the tool arrives as ordinary JavaScript inside the page, works the answer out on your own device and renders it in place, so the upload, queue and server-side record a typical online tool needs never happen
Where the work happens on a SysFenix page that has no file input at all: the tool arrives as ordinary JavaScript inside the page, works the answer out on your own device and renders it in place, so the upload, queue and server-side record a typical online tool needs never happen.

Frequently asked questions

Could a generated maze ever turn out unsolvable?

No, and not by luck. The carving algorithm produces a spanning tree over the grid, which is a structure with exactly one simple path between any two cells, so a start and a finish are always connected by exactly one route. The test suite checks this structurally on every generated maze rather than trusting the textbook property, including a negative control that opens one extra passage and confirms the path count then rises above one.

What grid size should I print for a classroom?

Medium (16x16) is the sweet spot for roughly ages 7 to 12, since its cells land near 32 points wide on A4, which is comfortable for a pencil line. Easy (10x10) suits younger children, and Hard (22x22) keeps most adults busy for a few minutes. Custom mode goes up to 40x40, where cells shrink to about 4.5 mm and a fine pen works better than a pencil.

Can I set different numbers of rows and columns?

Yes. Choose Custom and set rows and columns independently, anywhere from 5 to 40 each, so a 10 by 30 corridor maze is as valid as a square one. Cells stay square regardless, so the grid is sized by whichever dimension is tighter on the page and centred in the other.

Does the downloaded PDF match the maze I was looking at?

Yes. Download PDF builds the file from the exact maze currently in the preview, never a freshly generated one, so what you see is what prints. The on-screen preview is an SVG built from the same wall list the PDF drawing code walks, and the two share one geometry layer, so they cannot disagree about where a wall sits.

Why is there no circular or hexagonal maze option?

A polar maze is a genuinely different structure, built from concentric rings of sectors where the outer rings hold more cells than the inner ones, so the carving and solving math is not the row and column math this tool uses. Cropping a rectangular maze into a round outline would draw passages that lie about the maze's real topology, so we left it out rather than fake it.

Where does the randomness come from?

Each carving step picks its next neighbour with a crypto.getRandomValues-backed random integer helper shared with the random number generator tool, so consecutive clicks of Generate give genuinely different mazes rather than cycling through a small set. Tests swap in a fixed function instead, which is what lets a hand-traced 2x2 maze be asserted wall by wall.

Related tools