Random Maze Generator – Build Printable Mazes Instantly
The Random Maze Generator creates a unique, solvable maze on a rectangular grid in your browser — no drawing, drafting software, or manual layout required. Set the number of rows and columns, pick a generation algorithm, and click Generate to carve a brand-new maze in an instant. It is built for teachers preparing worksheets, puzzle enthusiasts, game designers prototyping dungeon or level layouts, and anyone who just wants a quick, one-of-a-kind maze to solve.
How Maze Generation Works
Internally, the maze is modeled as a grid graph: every cell is a node, and every potential wall between two adjacent cells is an edge. Generating a perfect maze — one with exactly one unique path between any two cells and no loops — means carving passages until the grid forms a spanning tree. The tool supports four classic algorithms, each producing a distinctly different texture:
- Recursive Backtracker — an iterative depth-first search that carves long, winding corridors with relatively few short dead ends.
- Prim's Algorithm — randomized minimum-spanning-tree-style growth that produces a denser, more uniformly branched maze.
- Kruskal's Algorithm — uses a union-find (disjoint-set) structure to merge random cell groups, spreading dead ends evenly across the grid.
- Binary Tree — the fastest and simplest method: every cell carves either north or east, producing a lightweight maze that is biased toward the top row and right-hand column.
Reproducible, Seeded Mazes
Every maze is generated with a seedable pseudo-random number generator (mulberry32), so the exact same seed, dimensions, and algorithm always reproduce the identical maze layout. Leave the seed field empty to get a fresh random maze on every click of Generate, enter a specific number to regenerate a maze you liked, or use Copy Link to share a maze with someone else via a URL that encodes the seed and settings.
Loops with the Braid Factor
A perfect maze has only one solution. Raising the Braid Factor slider removes a percentage of dead ends by carving an extra passage through them, which introduces loops and multiple valid routes between the start and end. A value of 0% keeps the maze perfect; higher values (up to 100%) make the maze progressively more open and less linear — useful for easier puzzles or more game-like level layouts.
Solving the Maze
Toggle Show Solution Path to run a breadth-first search (BFS) from the start cell to the end cell over the carved passages. Because BFS explores the graph level by level, it always finds the shortest possible route on an unweighted grid, which is displayed as a highlighted overlay along with its length in steps.
Customizing Your Maze
Choose the Start and End Position corners independently — if you accidentally pick the same corner for both, the tool automatically moves the end to the opposite corner so the maze always has a distinct entrance and exit. The Cell Size slider controls how large each cell renders on screen and in the downloaded image, and Download PNG saves the current view (walls, markers, and solution overlay if enabled) as an image file ready for printing or sharing.
Common Uses
Teachers use the generator to produce quick, unique classroom worksheets that are hard to memorize or copy from a neighbor. Puzzle enthusiasts generate a fresh maze whenever they want a new challenge. Game designers use small, braided mazes to prototype dungeon layouts or level graphs before building them in an engine. Because every maze is generated instantly in the browser with no file uploads or servers involved, you can regenerate as many mazes as you like at no cost.