Geohash encoder
Turn a latitude and longitude into a short geohash: 37.7749 and -122.4194 at nine characters become 9q8yyk8yt, a key about the size of a city block that groups nearby places together. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Latitude in decimal degrees
- 37.7749
- Longitude in decimal degrees
- -122.4194
- Precision
- 9
- Geohash
- 9q8yyk8yt
A geohash turns a pair of geographic coordinates into a short base32 string that identifies a rectangular cell on Earth. Nearby points share long common prefixes, which makes the encoding useful for proximity search, tile keys, cache partitions and human-readable location tokens. This capability takes latitude, longitude and a precision length, then returns the geohash string together with the cell bounding box. The algorithm is pure arithmetic: no network calls, no random sampling and no clock. Invalid precision or out-of-range coordinates are rejected with a clear input error instead of a silent wrong cell.
What a geohash actually represents
Geohash is a public encoding scheme that interleaves the bits of longitude and latitude, then packs those bits five at a time into a 32-character alphabet that deliberately omits ambiguous letters. Each character you add halves the cell roughly in one dimension and then the other, so longer strings describe smaller rectangles. A one-character hash covers a huge swath of the planet; nine or ten characters are typically fine enough for a city block or a building footprint, depending on latitude.
Because prefixes nest, two locations that share the first seven characters fall inside the same coarse cell, which is exactly what makes prefix queries and map clustering practical. The string is not a cryptographic hash: different points can share a prefix on purpose, and the same precision always yields the same string for the same coordinates. Use it when you need a compact, URL-safe key for a place rather than a full floating-point pair in every log line or database row.
How to choose precision and send coordinates
Send decimal degrees on the WGS84 globe: latitude from minus ninety to ninety, longitude from minus one hundred eighty to one hundred eighty. Precision is the number of base32 characters you want back, from one through twelve. Low values suit country or regional buckets; mid values suit cities and neighbourhoods; high values suit indoor-scale or vehicle-tracking cells.
Missing fields and non-numeric values fail the same way. Prefer stable decimal numbers rather than strings with units or cardinal letters; convert DMS or grid references before you call.
Where encoded cells fit in real pipelines
Because the transform is deterministic and side-effect free, you can regenerate the same key in the browser, in a worker, or in a batch job and expect byte-identical results for the same inputs. Remember that geohash cells are rectangles in degree space, not perfect circles of equal area: near the poles a long cell is much narrower in metres east-west than the same length near the equator. For strict radius search you still compute distance on the original points; use the hash for bucketing and candidate retrieval, then refine.
What you can do with it
Database and cache partition keys
Store a fixed-length geohash beside each record so range scans and cache shards group nearby locations without floating-point indexes.
Map clustering and tile labels
Bucket pins by shared prefixes at a chosen zoom-like precision, then expand only the cells that need detail.
Short location tokens in URLs
Replace long coordinate query strings with a compact geohash that still recovers a known cell when decoded elsewhere.
FAQ
What does this geohash encoder return?
It returns the geohash string, the latitude and longitude you submitted, the precision length, and the bounding box of the cell that string identifies.
What precision should I use?
Use fewer characters for large regions and more for fine cells. Values around seven to nine are common for city-block scale; twelve is the maximum this tool accepts.
What does it cost?
The page tool is free in your browser. Invalid inputs are not charged.
Why do nearby places share the start of their geohash?
Because cells nest inside each other: every extra character splits the parent cell into smaller pieces. Two places whose geohashes share the first seven characters sit in the same coarse cell, which is what makes prefix searches and map clustering work.
Is a geohash cell the same size everywhere on Earth?
No. Cells are rectangles in degrees, not circles of equal area, so near the poles a cell is much narrower east to west in meters than near the equator. For a strict radius search, measure distance on the original coordinates.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geo/geohash-encode \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"latitude":37.7749,"longitude":-122.4194,"precision":9}'const res = await fetch("https://api.kit.forhosting.com/geo/geohash-encode", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"latitude": 37.7749,
"longitude": -122.4194,
"precision": 9
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geo/geohash-encode",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"latitude": 37.7749,
"longitude": -122.4194,
"precision": 9
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geo/geohash-encode", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"latitude":37.7749,"longitude":-122.4194,"precision":9}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"latitude":37.7749,"longitude":-122.4194,"precision":9}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geo/geohash-encode", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"latitude": 37.7749,
"longitude": -122.4194,
"precision": 9
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geo.geohash_encode",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How to choose precision and send coordinates
The response echoes the inputs you sent, the resulting geohash, and the latitude/longitude bounds of the cell that string denotes. Those bounds are the intervals the encoder finished with after the last bit, so you can verify coverage without decoding separately. If precision is below one, or either coordinate sits outside its legal range, the call fails with invalid_input and is not billed.
Where encoded cells fit in real pipelines
Teams use geohashes as partition keys in time-series stores, as map-tile identifiers for client caches, as shared prefixes for nearby-point filters, and as short tokens in URLs or QR payloads when a full lat/lon pair is awkward. Run the free browser tool to inspect a single location, or call the API when you need the same encoding inside automation at $0.002 per successful request.
Technical questions
When does encoding fail?
It fails with invalid_input when precision is below one (or above twelve), when latitude is outside −90…90, when longitude is outside −180…180, or when a required number is missing or not finite.
Is the result the same in the browser and the API?
Yes. Both run the same pure encoder in lib.js, so identical inputs produce identical geohash strings and bounding boxes.