Maze Generator
Printable mazes at any size, with the solution.
Around 10 by 12 suits a five year old. A 20 by 26 takes an adult a few minutes. Past 35 across the corridors get narrow enough that a pen tip starts to matter more than the puzzle does.
Maze
How the Maze Generator works
Set the width and height and a fresh maze is carved on the spot, always solvable and never with a loop, because it is built as a spanning tree over the grid. The solution is one click away, which matters more for handing a child a hint than for checking it works.
Also known as: printable maze · make your own maze · maze puzzle maker · kids maze worksheet
How the maze gets carved
The grid starts with every wall standing. A walker begins in the top left, picks a random neighbouring cell it has not visited, knocks down the wall between them, and moves there. When it reaches a cell with no unvisited neighbours it backtracks along its route until it finds one, and carries on. When the stack empties, every cell has been visited exactly once and the maze is finished.
What this builds is a spanning tree: every cell is connected, and there are no loops anywhere. Those two properties are what make it a proper maze. Connected means there is always a route from start to finish. No loops means there is exactly one such route, so a solver who reaches the end knows they have solved it rather than found a shortcut.
The stack is kept explicitly rather than by recursion, which sounds like a detail and is not. A sixty by sixty maze can recurse thousands of levels deep in the worst case, which is enough to exhaust the call stack in some browsers and produce a blank page instead of a maze.
Why these mazes wind the way they do
Depth-first carving has a distinctive character: long winding corridors with relatively few junctions, and dead ends that run a fair distance before stopping. That comes directly from the walker committing to a direction until it runs out of unvisited cells.
Other methods give visibly different mazes from the same grid. Prim's algorithm, which grows from a frontier rather than a path, produces short branchy passages with junctions everywhere. Kruskal's gives something similar. Both are easier to solve, because a solver can see several options at once and eliminate them quickly.
Long corridors make the harder and more satisfying printed puzzle. A solver commits to a passage, follows it for some distance, and either arrives or has to come back, which is the experience people expect from a maze. That is the reason for the choice.
Sizing for the person solving it
Around eight by ten suits a four or five year old, where the goal is following a line rather than solving anything. Twelve by fifteen at seven. Twenty by twenty-six is a few minutes of work for an adult and is the default here.
The upper limit is set by the pen rather than the puzzle. Past roughly thirty-five cells across on A4, corridor width drops below about five millimetres, and tracing a route with a normal pen becomes an exercise in fine motor control rather than in navigation. If you want a genuinely hard maze, print larger paper rather than packing more cells onto A4.
Non-square grids are worth using. A tall narrow maze feels different from a square one, because the solution has a dominant direction and the dead ends run across it. Setting the height well above the width is the quickest way to get a maze that does not feel like the last one.
The solution, and what it is for
The solution is found by breadth-first search from the entrance, recording which cell each was reached from, then walking those links back from the exit. On a spanning tree any search would find the same path, since there is only one, but breadth-first is simple and never recurses.
Its main practical use is not checking that the maze works, which is guaranteed by construction. It is having something to show a child who has been stuck for ten minutes and is about to give up. Revealing the first third of the route is usually enough to restart them.
It is also a fast way to judge a maze before printing a stack. A solution that runs almost straight from corner to corner means the carving happened to be kind that time, and pressing New maze will usually give you something more interesting.
Uses beyond the obvious
Mazes turn up in occupational therapy for visual-motor integration work, where the task is following a path within boundaries and the difficulty is tuned by corridor width rather than by maze complexity. A large maze with wide corridors is a genuinely different exercise from a small one with narrow ones, and the size controls give you both.
Teachers use them as settling activities and as reward sheets, where the point is a few minutes of quiet concentration rather than anything curricular. Party bags and restaurant kids' menus are the same use in a different room.
There is also a small technical audience: people testing pathfinding code want mazes with known-correct solutions, and an SVG download with a guaranteed unique route is a convenient source of test cases.
Frequently asked questions
What size maze suits what age?
Roughly 8 by 10 for a four or five year old, 12 by 15 at seven, 20 by 26 for older children and adults. Past 35 cells across, the corridors get narrow enough on A4 that the width of your pen starts mattering more than the puzzle does.
Is every maze definitely solvable?
Yes, and there is exactly one route. The carving builds a spanning tree, which by construction connects every cell with no cycles, so there is always a path and never an alternative one.
Why do the passages wind so much?
That is the signature of depth-first carving: the walk commits to a direction until it dead-ends, which produces long corridors and few junctions. Other methods give short branchy passages that are noticeably easier. Long corridors make the better printed puzzle, which is why this one is used.
Can I get a maze with more dead ends?
Not directly, but a larger grid gives you more of them for the same style. Pressing 'New maze' also varies the character quite a bit, since the layout depends entirely on the random choices made during carving.
How do I print the maze without the solution?
The solution is off by default, so printing gives you the blank maze. Toggle it on and print again for your own copy. The maze itself does not change when you do.