Outdoors & maps

Encoded polyline converter

Encode or decode route coordinates at precision 5 or 6, with CSV and GeoJSON export.

Encoded polyline converter
Esc to restore

Your inputs

WGS84 decimal degrees, one latitude,longitude pair per line. An optional latitude,longitude header and blank lines are accepted. No exponent notation. Up to 10,000 points, 500,000 characters and 40 characters per coordinate.

Paste the raw string, without JSON quotes or escaped backslashes. Up to 120,000 characters and 10,000 decoded points. Leading/trailing whitespace is trimmed.

The encoded string does not store its precision. Choose the same precision used by its producer.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded or saved.

A clear answer. Here’s how.

Implements the encoded polyline algorithm: round coordinates, take latitude then longitude differences from the preceding point, zigzag signed integers, and emit five-bit groups with continuation flags and an ASCII offset of 63. Precision 5 scales by 100,000; precision 6 by 1,000,000 and must be selected explicitly. Decimal input is rounded exactly with integer arithmetic; halves go away from zero. Only decimal notation is accepted. Coordinates must be within latitude -90..90 and longitude -180..180 before rounding. Both modes are bounded to 10,000 points; coordinate input to 500,000 characters, encoded input to 120,000, and each encoded integer to six groups. Incomplete groups, odd coordinate counts and out-of-range decoded positions are rejected. Output represents the rounded route. CSV preserves latitude-first order; GeoJSON uses longitude-first WGS84 positions, a Point for one position or a LineString otherwise. Antimeridian crossings are not split, and no distance or routing is inferred. Generated strings are raw text; escape backslashes if putting one in source code or JSON. All processing is local.

How this is checked

4 reference checks passed These 4 cases were run when this page was built, on 3 December 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.

See the checks and where each expected answer comes from
  1. Case 1

    Inputs
    The tool’s default inputs
    Expected, and what Toolmoz gave
    text expected _p~iF~ps|U_ulLnnqC_mqNvxq`@, Toolmoz _p~iF~ps|U_ulLnnqC_mqNvxq`@
    Where the expected answer comes from
    Google Maps worked example: (38.5,-120.2), (40.7,-120.95), (43.252,-126.453), scaled to E5 and encoded as the published three-point string.
    Allowed difference
    exact
  2. Case 2

    Inputs
    Operation decode
    Expected, and what Toolmoz gave
    text expected latitude,longitude 38.5,-120.2 40.7,-120.95 43.252,-126.453, Toolmoz latitude,longitude 38.5,-120.2 40.7,-120.95 43.252,-126.453
    Where the expected answer comes from
    Inverse of the published Google Maps three-point example, with latitude and longitude in separate CSV columns.
    Allowed difference
    exact
  3. Case 3

    Inputs
    Latitude,longitude pairs -0.0000005,0.0000005Decimal precision 6
    Expected, and what Toolmoz gave
    text expected @A, Toolmoz @A
    Where the expected answer comes from
    At six decimals the exact half-away rule gives integers -1 and +1. Zigzag values 1 and 2 plus ASCII offset 63 give @ and A.
    Allowed difference
    exact
  4. Case 4

    Inputs
    Operation decodeRaw encoded polyline ??Output geojson
    Expected, and what Toolmoz gave
    text expected { "type": "Feature", "properties": { "precision": 5 }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }, Toolmoz { "type": "Feature", "properties": { "precision": 5 }, "geometry": { "type": "Point", "coordinates": [ 0, 0 ] } }
    Where the expected answer comes from
    Two question marks each encode a zero delta, so the single position is the origin. RFC 7946 represents a single position as a Point in longitude,latitude order.
    Allowed difference
    exact

What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

Operation
Encode coordinates
Latitude,longitude pairs
latitude,longitude
38.5,-120.2
40.7,-120.95
43.252,-126.453
Decimal precision
5 decimal places (Google example)
Output
Polyline when encoding; CSV when decoding

Example result

_p~iF~ps|U_ulLnnqC_mqNvxq`@

3 point(s), precision 5. Coordinates are rounded to the selected decimal places; exact halves round away from zero. A polyline does not identify its precision. CSV uses latitude,longitude; GeoJSON uses longitude,latitude. A single point exports as a GeoJSON Point. No map, location permission or network lookup is used.