Maze Generator

Choose the width and height and the style of passages. You get a maze with an entrance at the top left and an exit at the bottom right, and exactly one route between them. Print it, save it as a picture, or show the way through.

Worked examples

A 20 by 20 maze

20 across, 20 down

400 squares joined by 399 passages

A maze with no loops that joins n squares always has n minus 1 passages.

About Maze Generator

A maze is a good puzzle for children, a calming one for adults and a handy page for a party or a classroom. This generator makes one at the size you choose, from a tiny 3 by 3 to a sprawling 80 by 80, with an entrance at the top left and an exit at the bottom right. Print it, or save it as a picture.

Every maze is a perfect maze. All the squares are joined, there are no loops, and there is exactly one path between any two squares, so the way out is unique. Two styles are on offer. Long winding passages come from carving a path as far as it will go before backing up, which gives few dead ends but a long route. Many short dead ends grow the maze outwards from a random start, which gives lots of side turnings. Tick Show the solution to see the shortest route in orange. You can download the maze as an SVG, which stays sharp at any size, or as a PNG.

How to use Maze Generator

  1. Enter the number of squares across and down.
  2. Choose long winding passages or many short dead ends.
  3. Press New maze until you like the look of it.
  4. Press Print, or download it as SVG or PNG. Tick Show the solution when you want the answer.

Common uses

  • A rainy day activity sheet for children
  • A puzzle for a party bag or a treasure hunt
  • A classroom exercise for logic and planning
  • A decoration or a worksheet background

Frequently asked questions

Is there always a way through?

Yes. Every square is connected to every other by exactly one path, so there is always exactly one way from the entrance to the exit.

What sizes work best?

About 10 by 10 suits younger children, 20 by 20 suits most people and 40 by 40 or larger is a real challenge. Very large mazes print best on A3 or in landscape.

How is the solution found?

By searching outwards from the entrance until the exit is reached, then tracing back. That finds the shortest route, which in a perfect maze is also the only one.

Which download should I use?

Use SVG for printing at any size without blur or for editing in a drawing program. Use PNG for putting the maze into a document or sharing it as a picture.

Why does each maze look different?

The starting point and the choices made while carving are random, so there are an enormous number of different mazes at each size.