HEX COORDINATES
Hex Grid Calculator
Convert between cube, axial, and offset hex coordinates — with distance math.
COORDINATE MATH
Convert and measure hexes
| Hex | Cube | Axial | Offset (odd-r) |
|---|---|---|---|
| A | |||
| B |
Hex grid guide
Hex grids are the backbone of strategy games, and every developer hits the same wall: cube, axial, and offset coordinates, plus distance math that is nowhere near as simple as squares. This calculator converts between all three systems and computes hex distance instantly — the practical companion to Red Blob Games' classic guide.
Three coordinate systems, one grid
Cube coordinates (q, r, s) are the math-friendly form: three axes at 120°, with q + r + s = 0 always. Axial (q, r) drops the redundant third axis for storage. Offset coordinates (odd-r, even-r, odd-q, even-q) match how you lay out tiles in an array — column and row.
The trick every guide teaches: do the math in cube space, store in whatever fits your map, and convert only at the edges.
Distance the easy way
Cube distance is just (|Δq| + |Δr| + |Δs|) ÷ 2 — the same as Manhattan distance on a square grid, divided by two. That single formula powers movement ranges, AI pathfinding heuristics, and attack range checks.
Tip: If you ever need neighbors or paths, convert to cube once, run the algorithm, convert back. You will write far less buggy code than fighting offset math directly.
Frequently asked questions
What is the difference between axial and offset coordinates?
Axial (q, r) uses two axes with a 120° angle — compact and math-friendly. Offset uses plain column/row like a 2D array, with every other row shifted by half a tile. Offset is what you store in arrays; axial is what you compute with.
How do I calculate hex distance?
Convert both hexes to cube coordinates, then distance = (|Δq| + |Δr| + |Δs|) / 2. This tool does it for you in any input system.
Which layout should I use?
Pointy-top (odd-r offset) is the most common for strategy games and matches Red Blob's examples. Flat-top suits games where horizontal movement matters more.
Privacy note: hex coordinate calculations happen in your browser. Nothing is uploaded.