Fractal Maze Generator

Generate recursive mazes that contain smaller copies of themselves: going into a copy takes you one level deeper into the same maze.

A fractal maze is a maze that contains smaller copies of itself. Each copy is marked with a letter, and its doors are numbered like the exits of the maze. When you go into door 2 of copy A, you arrive at exit 2 of the maze, but now you are one level deeper: inside copy A. Inside it there are copies too, so you can go deeper and deeper, like piling up the levels of a stack. When you reach an exit from inside a copy, you leave that copy through the door with the same number and go back up one level.

To solve the puzzle, you go from the start S to the finish F of the main maze. Usually there is no direct path: you have to dive into the copies, go through the right doors and come back up at the right place, keeping track of both your position and the level you are in. This free online fractal maze generator creates a new puzzle every time, checks that it can be solved, and can show the solution step by step, drawn inside the copies where each part of the path really happens. You can print the maze, or play it in your browser, zooming into the copies as you go through their doors.

Everything runs directly in your browser: nothing is uploaded to a server.

Maze options

Hard picks the longest solution found by the generator.
Every copy has the same number of doors.
The maze has 24 x 24 cells.
The same seed always generates exactly the same maze.
Only 0 copies fit in the maze. Make the copies smaller than the maze by a larger number to fit more.

Look of the maze

The deeper levels are only drawn while they are large enough to see.
Only used by the play mode.
The exit numbers are drawn in the margin.

Solution

Maze details:
image: 100 x 100 px
maze: 0 x 0 cells
copies: 0
copies entered and left by the solution: 0
deepest level of the solution: 0

The maze image is 100 x 100 pixels. The checkered squares show the transparent areas of the image: they are not part of the downloaded PNG file.

How to solve a fractal maze?

The rules of a fractal maze are simple, but they make the puzzle feel completely different from an ordinary maze:

  1. Start at S and go to F - Both are in the main maze, the outermost level. Reaching the S or the F drawn inside a copy does not count.
  2. Go into a copy through a door - Every copy is the whole maze, shrunk. Going into door 3 of copy B takes you to exit 3 of the maze, one level deeper, inside copy B.
  3. Come out of a copy through an exit - When you reach exit 2 from inside a copy, you leave that copy through its door 2, and you are back one level up.
  4. Remember where you are - Write down the copies you entered, like a stack: "A, then C, then A". Leaving always takes you out of the last copy you entered, so you need the list to know where you come back.
  5. The exits of the main maze are closed - At the outermost level there is nowhere to go up to, so the exits are dead ends there.

A good way to solve a fractal maze is to first find, for each door, which other doors and exits it can reach directly through the corridors. The puzzle then becomes a smaller puzzle about these connections, and the solution can be worked out on paper.

Play the fractal maze in your browser

Click "Play this maze" to solve the maze directly on the screen. The image always shows the whole maze, because every level is the same maze: what changes is the level you are in, shown above the image as a list of the copies you entered ("Main maze › C › A") and by the color of the frame around the image.

  1. Walk - Click any cell you can reach, and the player walks there through the corridors. The arrow keys move one cell at a time.
  2. Go into a copy - Click a numbered door of a copy. The player walks to the door, and the image zooms into the copy until it fills the screen: you are now one level deeper, at the exit with the same number.
  3. Leave a copy - Click a numbered exit on the border of the maze. The image zooms out, and you come out through the door with the same number of the copy you were in.
  4. Undo and restart - "Undo" takes back the last move, and "Restart" puts you back at the start. A new seed, or any option that changes the maze, starts a new game.
  5. Win - Reach the F of the main maze. The tool then tells you how many copies you entered, compared with the shortest solution.

How to generate a fractal maze?

  1. Choose the difficulty - The generator tries many mazes and keeps the ones whose shortest solution goes through more copies. Hard picks the longest solution it found.
  2. Choose the number of copies and of exits - More copies and more exits create more ways to go, and longer solutions. Three copies and four exits make a good puzzle for most people.
  3. Choose the size - Set the cells per side of a copy and how many times the copies are smaller than the maze. The maze has (cells of a copy) x (scale) cells along each side.
  4. Click "Generate a new maze" - Every click picks a new random seed. Write down the seed to generate exactly the same maze again later.
  5. Customize the look (optional) - Draw the maze inside the copies (it is the same maze, shrunk), number the exits and the doors, and change the colors.
  6. Show the solution (optional) - The solution is drawn at its real place, inside the copies, with one color for each level, and it is also written step by step under the image.
  7. Download the maze - Click "Download maze image" to save the maze as a PNG file. Download it again with the solution to get the answer key.

How the fractal maze is generated

First, the copies and the exits are placed. Every exit sits in the middle of a cell that, once the maze is shrunk into a copy, becomes exactly one cell of the copy, so the doors of the copies always line up with the corridors. Then every terminal (an exit, a door of a copy, the start and the finish) grows a small random maze around itself, until the territories of all the terminals fill the maze.

The puzzle is decided by the walls between the territories: opening one joins two territories into one, so their terminals can reach each other. The generator opens and closes these walls, one at a time, and solves every maze it tries. Solving a maze with unlimited levels is possible because, from inside a copy, the only thing that matters is which exit you come out of: the generator calculates, for every pair of exits, the shortest way to go from one to the other inside a copy, and repeats this until nothing improves. It keeps the changes that make the shortest solution longer, and remembers every solvable maze it finds, so the easier difficulties can pick a shorter one.

Options

Below are all the options you can configure when generating a fractal maze.

FieldDescription
DifficultyHow long the shortest solution is. Hard takes the longest solution the generator found for this seed, medium about 60% of it and easy about 30% of it, counted in copies entered.
Number of copiesHow many smaller copies of the maze are placed inside it, from 1 to 6. They are named with the letters A, B, C and so on, from the top left to the bottom right.
Number of exitsHow many exits the maze has on its border, from 2 to 8. Every copy has the same number of doors, in the same places.
Cells per side of a copyThe size of a copy, in cells of the maze around it.
Copies smaller than the maze byHow many times the maze is shrunk to make a copy, from 3 to 6. A larger number makes the copies relatively smaller, which leaves more room for the corridors and for more copies.
SeedThe number that defines the maze. The same seed with the same options always generates exactly the same maze. The button "Generate a new maze" simply picks a new random seed.
Cell sizeThe size of one cell of the main maze in pixels. The size of the image is calculated from it.
Wall thicknessThe thickness of the walls of the main maze, in pixels. The walls inside the copies are shrunk with the copies.
Draw the maze inside the copiesDraws the maze again inside every copy, shrunk, which shows that every copy is the same maze. Turn it off for plain lettered boxes, like in the classic fractal maze puzzles.
Levels drawn inside the copiesHow many levels of copies inside copies are drawn, from 1 to 4. The levels that would be smaller than one pixel per cell are never drawn.
Number the exits / the doors of the copiesWrites the number of every exit in the margin, and the number of every door just inside each copy, so it is easy to see which exit each door leads to.
ColorsThe colors of the walls, of the inside of the copies, of the letters and numbers, of the start S, of the finish F and of the background. The background can also be transparent.
Color of the playerThe color of the dot that you move around in the play mode. The player is never part of the downloaded image.
MarginThe space around the maze, in pixels, where the exit numbers are written.
Show the solutionDraws the shortest solution and writes it step by step under the image. Every part of the path is drawn where it really happens: the parts inside a copy are drawn inside that copy, shrunk.
One color for each levelPaints the solution with a different color at each level, so you can follow the dives into the copies. Turn it off to use a single color.
Thickness of the solutionThe thickness of the line of the solution, as a percentage of the size of the cell at that level.

Frequently Asked Questions (FAQ)

What is a fractal maze?

A fractal maze is a recursive maze: it contains smaller copies of itself, and every copy contains copies too, forever. Entering a copy takes you one level deeper into the same maze, and leaving it takes you back one level up. The puzzle is solved by moving both through the corridors and through the levels.

Can I play the fractal maze online?

Yes. Click "Play this maze" and move with the mouse, a finger or the arrow keys. Going through a door zooms into the copy, and leaving it zooms out, so you can feel the levels as you go deeper. While you play, the arrow keys move the player instead of scrolling the page.

Is this fractal maze generator free?

Yes. The tool is completely free, there is no registration, and the maze is generated by your own browser: nothing is uploaded to a server.

Does every maze have a solution?

Yes. The generator solves every maze before showing it, and only keeps the mazes that can be solved and that need at least one trip into a copy. If no such maze is found with the chosen options, the tool shows a warning.

How deep can I go?

As deep as you want: every copy contains copies, so the levels never end. The solution of a generated maze only needs a few levels, shown in the maze details, but going deeper can be a trap that leads nowhere.

Is the solution unique?

Not always. The corridors of each level form trees, with no loops, but the levels can create more than one way to the finish. The solution shown is always one of the shortest, counted in copies entered.

Why can't I leave through an exit of the main maze?

The main maze is the outermost level, so there is no level above it to go to. In the main maze the exits are dead ends. Inside a copy, the same exits take you out of the copy.

Can I use the generated mazes commercially?

Yes. The mazes you generate are yours, and you can use them in puzzle books, worksheets, games, websites or any other project.

How do I generate the answer key?

Download the maze with the solution turned off, then turn on "Show the solution" and download the image again, without changing any other option. Both images are exactly the same maze, because the seed did not change.

Related tools

Maze Generator

Maze Generator

Generate random mazes and download them as images.
Hand-drawn Maze Generator

Hand-drawn Maze Generator

Generate random mazes that look drawn by hand, with smooth curves and bridges.
Sierpinski Triangle Generator

Sierpinski Triangle Generator

Draw the Sierpinski triangle, by dividing a triangle or by playing the chaos game.
Koch Snowflake Generator

Koch Snowflake Generator

Draw the Koch snowflake, the antisnowflake and the Koch curve.
Dragon Curve Generator

Dragon Curve Generator

Draw the dragon curve, the fractal you get by folding a strip of paper.
Mandelbrot Set Generator

Mandelbrot Set Generator

Draw the Mandelbrot set, zoom into it with the mouse and download the image.
Turtle Graphics

Turtle Graphics

Easily create Turtle Graphics images and animations.
Procedural Image Generator

Procedural Image Generator

Create images procedurally from basic shapes and mathematical formulas.