Maze Generator
Generate random, solvable mazes with custom dimensions, start/end points, and colors. Download as PNG, SVG, or animated GIF solution.
About Maze Generator
Welcome to the Maze Generator, a powerful tool for creating unique, solvable mazes instantly. Whether you need mazes for puzzles, games, education, or print materials, this generator offers full customization of size, entry and exit points, colors, and export formats. Every maze generated is guaranteed to have at least one solution path from start to end, making it suitable for puzzle creation, educational activities, and entertainment.
Key Features
- Custom Dimensions: Create mazes from 5x5 to 101x101 cells. Odd dimensions are recommended for optimal structure and proper wall placement.
- Flexible Entry and Exit Points: Place start and end points at corners or random positions along any edge of the maze for varied difficulty levels.
- Guaranteed Solvability: Every maze generated has at least one solution path connecting the start to the end, verified through Breadth-First Search pathfinding.
- Color Customization: Personalize wall colors, path backgrounds, start and end markers, and the solution line to match your preferences.
- Multiple Export Formats: Download your maze as a PNG raster image, SVG vector graphic for scalable printing, or an animated GIF showing the solution being traced step by step.
- Quick Size Presets: Jump to popular maze sizes including Small (11x11), Medium (21x21), Large (31x31), and X-Large (51x51) with a single click.
How It Works
Depth-First Search Maze Generation
The maze is generated using the Depth-First Search (DFS) algorithm with recursive backtracking. Starting from the top-left cell, the algorithm randomly selects unvisited neighboring cells, removes the wall between the current cell and the chosen neighbor, and continues exploring. When no unvisited neighbors remain, it backtracks to the last cell that has unexplored paths. This produces a perfect maze, meaning every cell in the grid is connected to every other cell by exactly one unique path. The resulting mazes are challenging with long, winding corridors and no loops.
Breadth-First Search Pathfinding
Once the maze is generated, a Breadth-First Search (BFS) algorithm finds the shortest route from the start point to the end point. BFS explores all cells level by level from the starting position, ensuring the first time it reaches the destination, it has found the optimal (shortest) path. This solution path is then highlighted on the maze in a distinct color and is also used to generate the animated GIF export.
Why Odd Dimensions?
The DFS maze generation algorithm operates on a grid where cells and walls alternate. Odd-numbered dimensions (such as 11, 21, 31) ensure proper wall placement around the maze perimeter and produce cleaner, more symmetrical maze structures. If you enter an even number, the tool automatically adjusts it to the next odd value to maintain structural integrity.
Usage Instructions
- Set the maze Width and Height using the quick size presets or enter custom values (5 to 101 cells, odd numbers recommended).
- Choose the Start Point and End Point locations from corners or random edge positions.
- Customize the color palette for walls, paths, start marker, end marker, and solution line.
- Click Generate Maze to create your custom maze with the selected settings.
- Download your maze in PNG, SVG, or as an animated GIF showing the solution.
Export Format Guide
- PNG: Raster image format ideal for printing, web use, and sharing. Fixed resolution based on the maze cell size.
- SVG: Scalable vector format that can be resized to any dimensions without quality loss. Best for large prints, posters, and professional design work. Also editable in vector graphics software.
- Animated GIF: Shows the solution path being drawn step by step from start to end. You can customize the GIF width and animation speed. Great for presentations, educational demonstrations, and social media sharing.
Applications of Maze Generators
- Puzzle Design: Create unique mazes for puzzle books, activity sheets, and brain teasers.
- Educational Activities: Use mazes to teach problem-solving skills, spatial reasoning, and algorithmic thinking.
- Game Development: Generate maze levels for video games, board games, and tabletop RPG campaigns.
- Art and Design: Create visually striking maze patterns for posters, coloring books, and decorative artwork.
- Event Planning: Design custom mazes for treasure hunts, escape rooms, and team-building activities.
Related Tools
- Sudoku Generator & Solver - Generate and solve Sudoku puzzles with configurable difficulty levels.
- Word Search Puzzle Generator - Create custom word search puzzles with your own word lists.
- Random Group Generator - Randomly split names into groups for activities and events.
- Random Name Picker - Pick a random name from your list for games and activities.
Frequently Asked Questions
What algorithm does this maze generator use?
This maze generator uses the Depth-First Search (DFS) algorithm with recursive backtracking for maze generation. DFS creates perfect mazes where exactly one path exists between any two points in the maze. For solving, it uses Breadth-First Search (BFS) to find the shortest path between the start and end points. BFS guarantees the optimal (shortest) solution.
Why are odd dimensions recommended for mazes?
Odd dimensions (like 21x21 or 31x31) are recommended because the DFS algorithm works on a grid where cells and walls alternate. Odd-numbered dimensions ensure proper wall placement around the maze perimeter and produce cleaner, more symmetric maze structures. Even dimensions are automatically adjusted to the next odd number to maintain structural quality.
Can I customize the colors of the maze?
Yes, you can fully customize five color elements of your maze: the wall color (maze barriers), path color (walkable area background), start point color (entry marker), end point color (exit marker), and solution path color (the line showing the route through the maze). Use the color pickers in the controls panel to personalize your maze appearance.
What export formats are supported?
You can download mazes in three formats: PNG (raster image, great for printing and web use), SVG (scalable vector graphics, perfect for any size including large prints), and animated GIF (shows the solution path being traced step by step from start to end). Each format serves different use cases for your maze projects.
Is every generated maze solvable?
Yes, absolutely. Every maze generated by this tool uses the DFS algorithm which creates perfect mazes, meaning every cell is connected and there is always at least one valid path between any two points, including the selected start and end positions. The BFS solver verifies this by finding the shortest possible route.
What controls the GIF animation speed and file size?
The animated GIF file size depends on several factors: the maze dimensions (larger mazes produce bigger files), the target GIF width setting, and the animation speed profile. The Fast speed option creates smaller files with fewer frames, while the Slow option produces smoother animations with more frames but larger file sizes. You can also set a custom GIF width to control the output dimensions.