Home › Fun & Games › Maze Generator

Maze Generator

Generate a fresh random maze in one click, pick its size and algorithm, then solve it right here with the arrow keys or print it for paper and pencil. Every maze has exactly one path from start to finish.

Last updated:

Difficulty
⏱ 0:00👣 0 moves

Tip: click the maze, then use the arrow keys or WASD. Hold Shift to run to the next junction. On phones, swipe on the maze.

Advertisement
Advertisement

How to use the Maze Generator

  1. Pick a size with the Easy / Medium / Hard / Expert buttons or type your own width and height.
  2. Choose an algorithm: the recursive backtracker makes long winding corridors, Prim's and Kruskal's make many short branches.
  3. Press Generate maze to create a new random maze. The maze code lets you recreate the same maze later.
  4. Play it: click the maze and use the arrow keys, WASD, swipes or the on-screen pad to walk from the green start to the orange finish. Hold Shift to run to the next junction.
  5. Show the solution, or print / download PNG for a paper maze with an optional answer key.

How the maze algorithms work

Every maze starts as a grid where every cell has four walls. The generator then knocks down walls until all cells are connected. Because a wall is only removed when it joins two parts of the maze that were not yet connected, the result is a perfect maze: a spanning tree of the grid with no loops and exactly one route between any two cells.

AlgorithmHow it worksWhat the maze looks like
Recursive backtrackerA randomized depth-first search. It walks to a random unvisited neighbour, removing the wall between, and backs up when it reaches a dead end.Long, winding corridors and relatively few dead ends. Usually the hardest to solve by eye.
Prim's (randomized)Keeps a list of cells next to the maze, picks one at random and connects it to a random cell that is already in the maze.Many short dead ends branching off in all directions; a "bushy" texture.
Kruskal's (randomized)Shuffles every wall and removes each one whose two cells are not yet connected, tracked with a union-find structure.Evenly spread short passages, similar to Prim's but with less bias toward the starting point.

The solution shown with Show solution is found with a breadth-first search, which always finds the shortest route. In a perfect maze it is also the only route that does not double back.

Tips for solving and printing mazes

  • Wall follower: keep one hand on the same wall (left or right) and you will always reach the exit of a perfect maze whose start and finish are on the outer edge.
  • Work backwards: on paper, starting from the finish is often quicker because dead ends near the exit become obvious.
  • Dead-end filling: shade every dead end back to the nearest junction; whatever corridors remain unshaded form the solution.
  • Printing: square sizes up to about 40×40 fit a portrait page well. For wide mazes such as 50×36, choose landscape in the print dialog.
  • Classroom use: share the maze code so every student gets the identical maze, and print the answer key for yourself.

Frequently asked questions

Does every maze have a solution?

Yes. All three algorithms build a perfect maze: every cell is connected and there is exactly one path between any two cells, so there is always a single route from start to finish with no loops.

What is the difference between the algorithms?

The recursive backtracker (a randomized depth-first search) carves long, twisting corridors with fewer dead ends. Randomized Prim's and Kruskal's algorithms grow the maze from many places at once, which gives lots of short dead ends and a busier look. All produce perfect mazes.

How do I print a maze?

Press Print. The maze is placed on its own page with a title, and you can tick Include answer key to add a second page with the solution drawn in. You can also download a PNG and print it from any app.

What size maze is good for kids?

For young children 8×8 to 12×12 is a good start. Older kids usually enjoy 15×15 to 25×25, and adults can try 40×40 or larger. Bigger mazes print best on landscape paper.

Can I make the same maze again?

Yes. Each maze shows a maze code. Type that code into the Maze code box with the same size and algorithm and press Generate maze to get the identical maze.

How do I play on a phone?

Swipe on the maze in the direction you want to go, or use the arrow pad below it. Your trail is shown so you can see where you have been.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Sudoku OnlinePlay free Sudoku with 4 difficulty levels, notes, hints and a timer.Jigsaw PuzzleTurn a sample picture or your own photo into a 12 to 150 piece jigsaw puzzle and solve it.Sliding PuzzlePlay the 15 puzzle and 3×3 to 6×6 sliding tile puzzles with numbers or your own photo.MinesweeperPlay classic Minesweeper: 3 difficulties, flags, timer and a safe first click.Connect the Dots MakerTurn a shape, drawing or image outline into a printable dot-to-dot worksheet PDF with answer key.Dots and BoxesPlay Dots and Boxes online vs a smart computer or a friend, on boards from 3×3 to 8×8.Nonogram PuzzlePlay unlimited nonogram (picross) puzzles from 5×5 to 15×15, each with one unique solution.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.SolitairePlay classic Klondike Solitaire with Draw 1 or Draw 3 and undo.Spider SolitairePlay Spider Solitaire online with 1, 2 or 4 suits, hints, unlimited undo and a timer.Play Chess vs ComputerPlay chess online against the computer at 8 difficulty levels.Connect FourPlay Connect 4 online against the computer or a friend.Snake GamePlay classic Snake online with speeds, wall modes and high scores.Tic Tac ToePlay tic tac toe against an unbeatable AI or a friend.Block Puzzle GameClassic falling blocks puzzle game with levels and high score.2048 GamePlay 2048 online with swipe controls, undo and best score.Word Guess GameGuess the hidden five-letter word in six tries. Unlimited games, stats and hard mode.HangmanClassic friendly hangman word game with categories, hints and difficulty levels.Memory Card GameFlip cards and match emoji pairs on 4×3 to 6×6 grids, with moves, timer and best scores.Flappy GameTap to flap a round chick through bamboo gaps and beat your high score.Dino Runner GameJump cacti and duck buzzing beetles in an original endless desert runner.Typing GameType the falling words before they land; level up and track your WPM and accuracy.Math Quiz GameTimed mental math rounds with four operations, five levels, streaks and high scores.Flag QuizGuess the flags of all 196 countries in four modes, from multiple choice to timed.Map QuizFind countries on a clickable world map or name the highlighted one, by continent.Periodic Table QuizLearn all 118 elements: quiz symbols, names and atomic numbers or click them on the table.Spelling Bee GameMake words from 7 honeycomb letters, always using the center letter. New daily puzzle.Mahjong SolitaireMatch pairs of free tiles to clear the Turtle and two smaller layouts, with hints, shuffle and undo.Scrabble Word FinderFind the highest-scoring words from your rack, with blank tiles, patterns and bingo bonus.Wordle SolverEnter your guesses and colours to see every possible answer and the best next guess.Crossword SolverFind words that fit a crossword pattern like c?t from the length and the letters you know.Word Search GeneratorMake a word search puzzle from your words, play it online or print it with an answer key.Pong GamePlay classic Pong online against the computer on 3 levels or with a friend, first to 11.Breakout GameClassic brick breaker game with levels, power-ups and lives. Play with mouse, touch or keyboard.Whack-a-MoleWhack the moles before they hide in 30 or 60 second rounds. Speed increases, best score saved.Simon Says GameRepeat the growing color and sound sequence. Classic memory game with strict mode and high score.CheckersPlay checkers online against the computer or a friend, with kings, undo and hints.ReversiPlay Reversi (Othello rules) online vs a 3-level computer or a friend, with move hints.Match 3 GameSwap gems to match 3 or more, trigger cascades and special gems, and beat each level's target.Snakes and LaddersPlay the classic board game online with 2-4 players or against the computer.Space Shooter GameRetro arcade space shooter: blast alien waves and meteors, grab power-ups and beat your high score.Spades Card GamePlay Spades online with a computer partner: bid tricks or nil, trump with spades, avoid bags.Stack Tower GameTap to drop sliding blocks and build the tallest tower. Perfect drops earn bonus points.US States QuizFind the 50 states on a clickable US map, type them all from memory, or match state capitals.Virtual Bubble WrapPop endless bubble wrap with click, touch or drag. Satisfying pop sounds and a pop-it fidget mode.Word Grid GameFind words in a 4x4 or 5x5 letter grid by dragging across adjacent letters before time runs out.Word Ladder GameChange one letter at a time to turn one word into another. Daily and random word ladders.Chess PuzzlesSolve chess puzzles online: mate in 1, 2 and 3 plus tactics, with hints, a rating and streaks.Clicker GameIdle clicker: mine gems, hire builders, buy upgrades, rebirth for stars and earn while you're away.Color by NumberTap numbered pixels to color pictures, or turn your own photo into a color by number puzzle.Online Coloring PagesColor animal, holiday and mandala pages online with bucket fill and brushes, then print or save PNG.Connections Word PuzzleGroup 16 words into 4 hidden categories. New daily puzzle, full archive, shareable results.Daily Crossword PuzzleA free new crossword every day: quick 5x5 mini or a bigger 13x13, with check, reveal and timer.Farkle Dice GamePlay Farkle online vs the computer or pass-and-play: pick scoring dice, risk it or bank to 10,000.Gin RummyPlay Gin Rummy vs the computer: draw, discard, knock or go gin. Melds found automatically.Jeopardy-Style Quiz Board MakerMake a categories-and-points quiz board, then play it full screen with teams and live scores.Name All Countries QuizType as many of the world's 197 countries as you can in 15 minutes while the map fills in.Piano Tiles GameTap the black tiles to play classic melodies. It speeds up as you go; beat your high score.Pinball GamePlay pinball online with real flipper physics, bumpers, a wire ramp, drop targets and multiball.8 Ball Pool GamePlay 8 ball pool online vs the computer or a friend: aim line, power meter, spin and real physics.Cube SimulatorTurn a 3D 2x2 to 5x5 puzzle cube online: drag or type moves, scramble, time solves and undo.TriPeaks SolitairePlay TriPeaks Solitaire free: clear three peaks with up-or-down runs, streak bonuses, undo and hints.Water Sort PuzzlePour colored water between tubes until every tube holds a single color. Endless solvable levels.20 Questions GameThink of an animal or object and the game guesses it with yes/no questions, then learns.24 GameCombine four numbers with + − × ÷ to make 24. Endless solvable hands, timer and a solver.Asteroids GameClassic vector Asteroids arcade: rotate, thrust and blast space rocks into pieces, wave after wave.Basketball Shooting GameDrag and release to shoot hoops against a 60-second clock, with moving-hoop levels and combo bonuses.Bible Trivia QuizMultiple-choice Bible trivia by book and difficulty, with verse references and a kids mode.
See all 141 Online Games →