The grid model, the formula, and how the numbers are measured
Every tile has the same size. The margin is skipped once before the first column (and row), the spacing sits between two neighbouring tiles, and nothing is assumed after the last tile. Tile (c, r) therefore starts at x = margin + c × (tile + spacing), y = margin + r × (tile + spacing). Godot names the same numbers Texture Region Size, Margins and Separation; Tiled names them tile size, Margin and Spacing.
n tiles need margin + n × tile + (n − 1) × spacing pixels, so the most that fit is floor((W − margin + spacing) ÷ (tile + spacing)). With the same margin on both sides the textbook form (W − 2 × margin + spacing) ÷ (tile + spacing) comes out exact; Nerulio's floor gives the same count whenever the leftover strip on the right is narrower than one tile plus spacing, which is also why a sheet with a few spare pixels still slices cleanly.
The detector reads the image one line at a time: how much each row and column differs from the previous one. It folds that profile at every period from 4 px to half the image and keeps the periods that explain the most of its variation, then checks the phase, and demands that every line a margin or spacing claims is really blank or flat. When the first or last line of every tile is blank, "16 px + 1 px spacing" beats "17 px tiles"; a multiple of the true size loses when a divisor scores within 0.02 of it. The Studio also tries the sizes at which a published autotile layout fits exactly.
It is weakest where a sheet gives no separators: packed tiles whose interiors are busier than their borders. It cannot measure one tile per axis, and the Studio measures images up to 16 megapixels; above that, type the size.
- Tile size
- Width and height of one tile in pixels (Godot: Texture Region Size).
- Margin
- Pixels before the first tile, at the left and top edge.
- Spacing
- Pixels between two neighbouring tiles (Godot: Separation). Often 1 px, sometimes extruded border pixels.
- Packed sheet
- Tiles edge to edge, no spacing: the easiest for other editors, the hardest to measure.
Example: two Kenney sheets from the test corpus
Measured with Nerulio's grid detector on the CC0 files (2026-09-28):
Kenney Tiny Dungeon tilemap.png 203 × 186 px 16 px tiles, 1 px spacing, margin 0
columns = floor((203 − 0 + 1) / (16 + 1)) = floor(204 / 17) = 12
rows = floor((186 − 0 + 1) / (16 + 1)) = floor(187 / 17) = 11 → 132 tiles
tile 13 = column 1, row 1 → x = 0 + 1 × 17 = 17, y = 17, size 16 × 16
detected: 16 × 16, spacing 1, 12 × 11, score 0.976 (high)
tilemap_packed.png 192 × 176 px same tiles, no spacing → 192 / 16 = 12, 176 / 16 = 11
detected: 16 × 16, 12 × 11, but score 0.514 (low): no blank line between tiles
Kenney Pixel Platformer tilemap.png 379 × 170 px → (379 + 1) / (18 + 1) = 20, (170 + 1) / 19 = 9
its tiles are 18 px, not 16: detected 18 × 18, spacing 1, 20 × 9, score 0.946 (high)
The same art scores 0.976 with gaps and 0.514 without them: blank separator lines are the strongest evidence a sheet can give. On a packed sheet, look at the dashed grid before you press Use this grid, or type the size you know.
Check the grid before you use it
- The dashed lines sit in the gaps all the way to the last column and the last row. If they are right on the left and wrong on the right, the tile size or spacing is off.
- Columns × rows match what you expect (12 × 11 = 132 for Tiny Dungeon), and the tiles counted as blank are really empty.
- After export, Godot's atlas shows the same Texture Region Size, Margins and Separation; Nerulio's Godot export with margin 1 and spacing 2 reached
TileSetAtlasSource unchanged in Godot 4.7.2. - For single tile PNGs, the classic slicer's tiles are copied region by region, never resampled: each one equals its source rectangle byte for byte.
Troubleshooting
| Symptom | Likely cause | How to check | Fix |
|---|
| Tiles drift further off with every column | Wrong tile size: Pixel Platformer's 18 px tiles read as 16 px + 1 px put tile c at 17 × c instead of 19 × c, 2 px more off per column | The grid fits the first column and misses the tenth by 18 px | Take the candidate with 18 px, or type tile 18, spacing 1 |
|---|
| Every tile is cut 1 px too far up and left | A border was not declared as margin | The first row and column of the image are blank or one flat colour | Set margin 1; the count formula subtracts it once |
|---|
| A partial column or row is left at the right or bottom | The tile size does not divide the sheet; the floor drops anything narrower than one tile plus spacing | Compute (W − margin + spacing) ÷ (tile + spacing): it should be a whole number or just above one | Recheck the tile size; a remainder of many pixels means the reading is wrong, not the sheet |
|---|
| The top candidate is only low or medium | A packed sheet: nothing blank between tiles, and busy tile interiors | Score and confidence next to each candidate | Confirm the dashed grid, pick another candidate, or type the size |
|---|
| No candidates at all on a huge image | The Studio measures sheets up to 16 megapixels | Image width × height | Type the tile size, margin and spacing by hand |
|---|
| Another editor refuses the sheet | Some editors take no spacing: Sprite Fusion asks that the tileset width and height be exact multiples of the tile size | Does W ÷ tile give a whole number? | Use the packed version of the sheet, or repack it without gaps |
|---|
Other ways to do it
| Option | When it is the better choice |
|---|
| Type the numbers in the engine: Godot's atlas (Texture Region Size, Margins, Separation) or Tiled's new-tileset dialog (tile size, Margin, Spacing) | You already know the grid, for example from the asset pack's readme. |
|---|
| The classic tile grid slicer | You want every tile as its own PNG, exact and near duplicates found, rotated and flipped variants, or an extruded atlas against bleeding. |
|---|
| The sprite slicer | The sheet has sprites of different sizes with no grid; tile slicing needs a regular grid. |
|---|
What this page does not cover
- Regular grids only; isometric or hexagonal sheets are not modelled.
- The Studio does not write one PNG per tile; that stays in the classic slicer.
- A sheet with a single tile per axis has no period to measure.
Versions and sources
The formula and the rectangles are those of tileRects in src/game/tile-grid.js; detection was checked on 10 synthetic sheets (true grid first in 10 of 10) and the Kenney numbers above were measured on the corpus files on 2026-09-28. The Godot 4.7.2 run of 2026-09-22 read margin 1 and separation 2 back from the built TileSet. Engine field names follow the linked documentation.
Official documentation used
Tileset Slicer
Slice a tile sheet with margin and spacing into individual PNGs plus a metadata JSON.
How it works
- Add images
- Adjust settings and review the result
- Download a new file
Supported formats
PNG / JPG / WebP / AVIF / HEIC → PNG + JSON (ZIP) — Input decoding depends on browser support and optional engines.
What this tool does
Slice a tile sheet with margin and spacing into individual PNGs plus a metadata JSON.
Implementation and verified quality
advanced · Studio Tile workspace: seam-continuity layout identification, terrain bits, Godot 4 terrain matcher port, quarter-exact generator, Godot/Tiled/LDtk/Unity writers. Quality qualification is in progress. Pro/Flagship quality has not been established.
Before you export
Regular grids only. Irregularly placed sprites belong in the sprite slicer.