geoprimsField-grade geospatial math

S2 token and cell id

Converts an cell between its compact hexadecimal token and its 64-bit decimal cell id, with its level and face.

8085809c

The token 8085809c is cell id 9260949616260546560, at level 13.

Cell id
Level
Face
Provenance
Computed by
indexing.s2.token 1.0.0, core 0.1.0
Model
S2 geometry and Web Mercator tile arithmetic, as the general S2 and tile tools compute them
Accuracy
Exact for indexes and tokens; S2 areas to the precision of the cell's spherical polygon
Notes
None
Cites
Google, S2 Geometry

Something look off?

Your values

Showing an example. Change anything.
Run many at once from a CSV

Loading…

How we got thisFormula, worked example, sources, and proof

Model: S2 geometry and Web Mercator tile arithmetic, as the general S2 and tile tools compute them

Accuracy: Exact for indexes and tokens; S2 areas to the precision of the cell's spherical polygon

When to use this: Use this when S2 cells arrive in one form and a system wants the other: BigQuery and many APIs use the 64-bit decimal id, while URLs, logs, and the S2 libraries' debug output use the short hexadecimal token. Paste either. The tool returns both, with the cell's level and cube face, so you can check they name the same cell.

Limitations: Tokens drop trailing zeros, so they vary in length with the level; leading zeros are not dropped. A decimal id longer than 16 digits is read as an id and anything shorter as a token, since a short decimal number is also a valid hexadecimal token. Signed 64-bit stores may show the same id as a negative number.

Worked example: A level 13 cell over San Francisco. Source: S2 and slippy-map conventions, computed by the core. It is golden test vector v001, and every build checks the tool still gives its answer within its tolerance.

You enter

S2 cell
8085809c

You get

S2 cell
8085809c
Cell id
9260949616260546560
Level
13
Face
4

Review: Not yet independently reviewed by a GIS professional.

Last verified: 2026-09-22, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.0, core 0.1.0. See this tool in the verification report.

Changes

Checked against: 21 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources

Terms

S2: S2 Geometry
A way of indexing the sphere: the Earth is projected onto a cube, each face is traced by a Hilbert curve, and a cell is a position along that curve at a level from 0 to 30. Source: S2 Geometry

S2 — S2 Geometry

A way of indexing the sphere: the Earth is projected onto a cube, each face is traced by a Hilbert curve, and a cell is a position along that curve at a level from 0 to 30.

Source: S2 Geometry