Logo

MonoCalc

/

Random Maze Generator

Random
2-50
2-50
Random each time
How to use

Set the grid size and algorithm, then click Generate. Enable Show Solution Path to reveal the shortest route, adjust Braid Factor to add loops, and use Download PNG to save a printable copy.

About This Tool

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.

Tip
Keep grid sizes reasonable for printing — a 15x20 or 20x25 maze fits comfortably on a letter or A4 page, while very large grids (up to the 2,500-cell limit) are better viewed on screen.

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.

Frequently Asked Questions

Is the Random Maze Generator free?

Yes, Random Maze Generator is totally free :)

Can I use the Random Maze Generator offline?

Yes, you can install the webapp as PWA.

Is it safe to use Random Maze Generator?

Yes, any data related to Random Maze Generator only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does the Random Maze Generator work?

Set the number of rows and columns, pick a generation algorithm, and click Generate. The tool carves passages through a grid of cells using a seeded random number generator, producing a maze with exactly one path between the start and end cell (a 'perfect' maze) unless you enable braiding for loops.

What's the difference between the generation algorithms?

Recursive Backtracker produces long, winding corridors with few short dead ends. Prim's Algorithm creates a denser, more uniformly branched texture. Kruskal's Algorithm spreads dead ends evenly across the grid. Binary Tree is the fastest and simplest, but is biased toward passages running along the top row and right column.

What does the seed value do?

The seed feeds a reproducible pseudo-random number generator, so the exact same seed, dimensions, and algorithm always regenerate an identical maze. Use Copy Link to share a maze with someone else, or leave the seed blank to get a new random maze each time.

What is the Braid Factor?

Braid Factor is the percentage of dead ends that get an extra passage carved through them, turning a single-solution 'perfect' maze into one with loops and multiple valid routes. A value of 0% keeps the maze perfect; higher values create progressively more open, less linear mazes.

Can I print or download the generated maze?

Yes. Click Download PNG to save the current maze (with or without the solution overlay) as an image file suitable for printing or sharing, for example as a classroom worksheet or puzzle handout.

How is the solution path calculated?

When Show Solution is enabled, the tool runs a breadth-first search from the start cell to the end cell over the carved passages, which guarantees the shortest possible route through the maze on an unweighted grid.