Skip to content
AZ Tools

Geohash Encoder

Convert between latitude/longitude and geohash strings (Niemeyer 2008). Adjustable precision 1-12, with bounding box and 8 neighbor cells.

Cities
Geohash
wydm9qy89
Center coordinate
37.566483, 126.977985
Bounding box
S 37.566462, W 126.977963
N 37.566504, E 126.978006
8 neighbors + center
NW
wydm9qy8b
N
wydm9qy8c
NE
wydm9qy8f
W
wydm9qy88
center
wydm9qy89
E
wydm9qy8d
SW
wydm9qy82
S
wydm9qy83
SE
wydm9qy86

Cell size halves alternately by character. Precision 9 (~5 m) is good for delivery; 5 (~5 km) for city-scale proximity.

How to use

  1. Encode mode: enter lat/lng (decimal degrees, e.g. 37.5665, 126.978) and pick precision.
  2. Decode mode: paste a geohash; you get the center coordinate and bounding box.
  3. Neighbors are computed automatically — useful for 'find points near X' queries that should also check the 8 surrounding cells.

About this tool

Show

Geohash folds a latitude and longitude into a short base-32 string by repeatedly halving the world and recording which half the point fell in. The bits alternate between longitude and latitude, five bits per character, so every character you add divides the cell by 32. Encode a coordinate to any precision from 1 to 12, decode one back with its bounding box, and see all eight neighbouring cells.

The property that makes it useful in a database is the prefix: two locations in the same cell share a prefix, so a LIKE 'u4pruy%' or a range scan on a sorted key finds everything nearby without a spatial index. Redis GEO, older MongoDB deployments and plenty of hand-rolled systems lean on exactly this.

The cells are not square, and the shape alternates. Because the bits alternate between the two axes, an even-length geohash has spent one more bit on longitude than latitude: precision 8 gives a cell about 38 metres wide and 19 tall at the equator, while precision 9 is roughly 4.8 metres in both directions. Precision 5 is about 4.9 km square and precision 12 is a few centimetres. If you are choosing a precision for a radius query, the number to reason about is the smaller dimension.

Two limitations to design around. Cells shrink toward the poles because a degree of longitude does: that 38-metre cell is 30 metres across in Seoul, 19 at 60° north and 13 at 70°. A precision chosen for one city is a different size in another. And the prefix property fails exactly where it would be most convenient — two points a metre apart can share no prefix at all if a cell boundary runs between them, and the major boundaries sit on the equator and the prime meridian. That is why the eight neighbours are shown here rather than treated as an afterthought: a proximity query that checks only the centre cell will miss points that are closer than ones it finds.

Frequently asked questions

What's the alphabet?

Base-32 with characters 0-9bcdefghjkmnpqrstuvwxyz — the letters a, i, l, o are excluded to reduce ambiguity (looks like 4, 1, 1, 0). This is the standard Niemeyer alphabet used by every geohash library.

How precise is each level?

Cell size halves alternately in longitude and latitude per character. Approximate cell widths at the equator: 1→5000 km, 3→156 km, 5→4.9 km, 7→153 m, 8→38 m, 9→4.8 m, 12→3.7 cm. Cells get narrower toward the poles.

Why are neighbors useful?

Geohash cells form a grid. A point near a cell boundary may have its nearest neighbor in an adjacent cell — so 'find points within 1 km' shouldn't just query the target cell, it should query the 3×3 block. The neighbor function gives you the 8 surrounding hashes to OR into your query.

Two nearby places have completely different geohashes. Why?

Because the grid has fixed boundaries, and points on opposite sides of one share no prefix at all — the clearest case is the equator and the prime meridian, where neighbouring points differ from the first character. Prefix length is therefore a lower bound on closeness rather than a measure of it: a shared prefix proves proximity, but its absence proves nothing.

How do I search a radius with geohashes?

Take the cell that contains the centre at a precision whose cell is comparable to your radius, add its eight neighbours, and query for anything whose hash starts with one of those nine prefixes. That covers the circle with a slightly larger square region, so filter the results by real distance afterwards — the prefixes are an index, not the answer.

Related tools