Location technology

    What Is a Geohash and How Does It Work?

    A geohash encodes a latitude and longitude as a short string of letters and digits, where longer strings mean smaller areas. Learn how it works.

    Updated 14 October 2026 · 3 min read

    A geohash is a way of converting a latitude and longitude into a short text string. Each additional character narrows the location to a smaller rectangle, so longer strings are more precise. It was designed to be simple to store, sort and search in databases, and it is used widely by developers.

    How it is built

    The algorithm repeatedly halves the world:

    1. Start with the full range of longitude (-180 to 180) and latitude (-90 to 90).
    2. Alternate between the two. For longitude, decide whether the point is in the western or eastern half and record a 0 or 1. Then do the same for latitude.
    3. Keep halving the chosen range to produce a long sequence of bits.
    4. Take the bits in groups of five and map each group to one character from a 32-symbol alphabet of digits and letters.

    The result is a string such as gcpvj, which names one cell. The alphabet leaves out a few letters that are easy to confuse.

    Precision by length

    Each character adds five bits, so the cell becomes smaller step by step. As a rough guide, cells are:

    Characters Approximate cell size
    1 thousands of km across
    4 tens of km
    6 about a kilometre
    8 tens of metres
    9 a few metres
    10 about a metre or less

    The cell shape is a rectangle in degrees, so its width in metres depends on latitude, as explained in how long a degree is.

    The prefix property

    Because each hash extends the previous one, locations within the same cell share a prefix. This makes it easy to search for nearby places: find records that start with the same characters. Prefix matching is quick in a standard database index, which is a major reason developers like geohashes.

    Caveats

    • Neighbours can have different prefixes. Two points close together on opposite sides of a cell boundary may share no characters at all. Proximity searches usually check the neighbouring cells as well.
    • Cell shapes vary. Cells are narrower in east-west distance away from the equator.
    • Not designed for people. The strings are compact but not meaningful or error-checked for human use.

    How it compares

    Geohash is a general-purpose spatial index. Other systems such as Plus Codes or MGRS have different goals and encodings. The underlying idea, dividing the Earth into addressable cells, is shared by how location codes are generated from coordinates in general.

    Frequently asked questions

    Does a geohash identify a point or an area?

    An area. Each geohash names a rectangular cell, and longer hashes name smaller cells inside it.

    Why do nearby places share a prefix?

    Each extra character subdivides the previous cell, so places in the same cell share the characters that identify it.