Dungeon generator
This dungeon generator draws a room-and-corridor map from a seed number, exports it as a PNG and as a JSON grid for your game, and lets you walk the map in your browser.
Change a setting or press New seed. Every map has a seed, so you can get it back.
Seed 2026 · 14 of 14 rooms placed · 16 corridors · 655 floor cells · shortest walk from start to exit: 76 steps
What each setting does
Map size sets the grid. Small is 40 × 30 cells, medium 64 × 44 and large 96 × 64. Larger maps also get larger rooms, up to 13 cells across.
Rooms is a request, not a promise. Rooms are placed at random and any that would touch another are thrown away, so a small map asked for 40 rooms ends up with fewer. The line under the map says how many were placed.
Density adds loops. At 0% the corridors form a tree with exactly one fewer corridor than rooms, so there is one route between any two rooms. At 100% about seven extra corridors are added for every ten rooms.
The seed repeats a map. With seed 2026 and 14 rooms on a medium map, density 0% gives 13 corridors and density 100% gives 23, on the same rooms.
Walk the map before you build the game
Play this map turns the current dungeon into a small top-down game. You start on the green cell, see seven cells around you through line of sight, and the rooms you have seen stay dimly drawn. Find the orange stairs. The counter shows your steps next to the shortest possible walk, which for the map above, seed 2026, is 76 steps across 655 floor cells.
Walk with the arrow keys or W A S D. On a phone the four buttons under the map do the same. A map that feels tedious to cross, or has a dead end where you hoped for a room, is easier to spot by walking it than by looking at it. The exit is always the floor cell farthest from the start by walking distance.
Use the JSON in a game
The file holds the format name, the seed and settings, the grid size, a grid array of text rows, every room as an x, y, width and height, and the start and exit cells. Loading it takes a short loop:
const map = await (await fetch("./dungeon-2026-medium.json")).json();
for (let y = 0; y < map.rows; y++)
for (let x = 0; x < map.cols; x++)
if (map.grid[y][x] === "#") addWall(x, y); // your tile code
player.x = map.start.x; player.y = map.start.y;
exitDoor.x = map.exit.x; exitDoor.y = map.exit.y;To have Claude Code build the level from the file, give it a prompt like this one in a session that has the starters installed:
Read dungeon-2026-medium.json. Build a top-down game in the topdown-shooter starter whose level is that grid: # is wall, . is floor, the player starts at start.x and start.y, and reaching exit.x and exit.y wins the round. Keep the starter's controls, play it, and check that every room can be reached.Other dungeon generators
donjon's random dungeon generator is built for tabletop games: dungeon level, party size, motif, doors, stairs and a random seed field. Gozzys.com's dungeon map generator numbers every map, downloads a detailed image and a Universal VTT file for virtual tabletops. Choose them to run a table game.
This page makes the map for a video game: a text grid to load, a PNG to look at, and a walk to test the layout. Bob Nystrom's Rooms and Mazes describes a related method: random rooms first, then mazes in the space between them. This generator keeps the rooms and joins them with short L-shaped corridors instead.
Questions
How do I generate a dungeon map?
Pick a map size, set how many rooms you want and how dense the corridors are, and press New seed until a layout looks right. Export PNG saves a picture of it, and Export JSON saves the grid, the rooms, the start and the exit for a game to load.
What is a seed in a dungeon generator?
A seed is the number that drives every random choice, so the same seed with the same settings always draws the same dungeon. Write down the seed and the three settings and you can get a map back, or send it to someone else who can rebuild it.
How does a dungeon generator work?
This one drops rooms at random and rejects any that touch, joins them with a minimum spanning tree of corridors so every room can be reached, then adds extra corridors to make loops. The density slider sets how many extra corridors are added.
How do I load the dungeon JSON in a game?
Read the grid array: each string is one row, a # is a wall and a . is floor. The start and exit objects give the cell where the player begins and where the level ends. Loop over the rows once to build tiles, collision and a minimap.
Put your assets into a playable game. Try the ten game templates or get the kit.