February 14, 2026

What Is a Geohash? Encoding Locations for Databases

Geohash encodes any latitude/longitude pair as a short alphanumeric string. It's the secret behind fast proximity queries in Redis, PostgreSQL, and Elasticsearch.

When you search for "coffee shops near me" on an app and the results appear instantly, there's a good chance a Geohash is doing the heavy lifting behind the scenes. Geohash converts any latitude/longitude pair into a compact alphanumeric string that encodes proximity — and that's exactly what makes it so powerful for databases.

How Geohash Works

Geohash recursively divides the world into a grid of rectangles. At each step, the grid is split in half — first horizontally, then vertically, alternating — and a bit is assigned based on which half the point falls in. After 45 steps (for a 9-character hash), the result is encoded in base32 using the characters 0123456789bcdefghjkmnpqrstuvwxyz.

The result for the Eiffel Tower (48.8584, 2.2945) is u09tunquc. The key insight: two geohashes that share a common prefix are geographically close to each other. All points beginning with u09t are within a few kilometres of Paris.

Geohash in Production: Redis and PostgreSQL

This prefix property makes geohash ideal for database proximity queries:

  • Redis has a native GEOADD / GEODIST / GEORADIUS command family that internally uses geohash
  • PostgreSQL — you can index a geohash column with a B-tree index and use LIKE 'u09t%' to find all records in a region, orders of magnitude faster than bounding-box lat/lon queries
  • Elasticsearch supports geohash grid aggregations natively

Precision Levels

Geohash length controls precision:

  • 5 characters ≈ 4.9 km × 4.9 km
  • 7 characters ≈ 152 m × 152 m
  • 9 characters ≈ 4.8 m × 4.8 m

For most proximity use cases, a 6–7 character hash strikes the right balance between precision and query efficiency.

Limitations

Geohash has one important edge case: two geographically adjacent points can have completely different hashes if they fall on opposite sides of a grid boundary. Production implementations handle this by querying not just the target cell but all 8 neighbours as well.

Use our coordinate converter to generate a Geohash for any coordinate, or our DD to Geohash guide to understand the encoding by hand.