Maze Solver
Draw a maze on the grid, place a start and an end, and get the shortest path with a plain-text route. It runs in your browser and nothing is sent anywhere. The example maze below is ready to solve.
Tap or press Enter on a cell to use the selected tool. On a keyboard, the arrow keys, Home and End move between cells, and W, S and E toggle a wall, move the start or move the end.
Not solved. Press Solve to find the shortest path on this board.
How to use the maze solver
- Set the board size, up to 40 rows by 40 columns, or start from the example.
- With the Wall tool selected, tap cells to add or remove walls. Use the Start and End tools to move the endpoints.
- Press Solve. The path appears on the board, and the result below it gives the number of moves and the route.
- Print the board or download it as text. Both show the board as it is now, so an edit removes the old solution from them.
How the solver finds the shortest path
The solver uses breadth-first search. Every move on this grid costs the same, one step up, right, down or left, so the search can work outward in rings: first every cell one move from the start, then every cell two moves away, and so on.
Each cell remembers the neighbor it was first reached from. When the search reaches the end, following those links backward gives the route. No shorter route can exist, because a shorter one would have reached the end in an earlier ring. A maze can have several routes of the same shortest length; the solver shows one of them.
If the search runs out of cells without reaching the end, no path exists, and the result says so. Diagonal moves are not allowed, so two walls touching at a corner block the way between them.
For how this differs from depth-first search, which can find a route but not necessarily the shortest one, read BFS vs DFS.
Reading the exported board
The text download has one character per cell, followed by the result for that board.
.open cell#wallSstartEend*cell on the shortest pathsstart on a walleend on a wallBstart and end on the same cellbstart and end on the same wall
What it does not do
It solves the grid you draw. It does not read photos or screenshots of a maze, and it does not generate mazes.