LazyTools

🔒 Every tool runs in your browser — the files and values you enter are never uploaded to any server. How it works

📍 Google Polyline Encoder / Decoder

Decode a Google Maps polyline string into coordinates (and GeoJSON), or encode a list of lat/lng points into one — with precision 5 or 6.

3 points (lat, lng)

38.5, -120.2
40.7, -120.95
43.252, -126.453

GeoJSON LineString

{
  "type": "LineString",
  "coordinates": [
    [
      -120.2,
      38.5
    ],
    [
      -120.95,
      40.7
    ],
    [
      -126.453,
      43.252
    ]
  ]
}

Encode a list of latitude/longitude points into a Google-encoded polyline string, or decode one back into coordinates (and GeoJSON). It's the compact format the Google Maps Directions API returns for routes. Remember polyline order is latitude, longitude — the reverse of GeoJSON's. Use precision 6 for the higher-precision variant some services use. Everything runs in your browser. 🔒

Rate this tool:
Anonymous — no account, no identifier

How the google polyline encoder / decoder works

Google's Encoded Polyline Algorithm squeezes a list of latitude/longitude points into a short ASCII string — the compact form the Google Maps Directions API returns for a route. Each point is stored as the difference from the previous one, scaled by 10^precision (5 by default), zig-zag encoded to handle negatives, and split into base-32 chunks written as printable characters. This tool implements that algorithm exactly, both ways: paste an encoded string to decode it into coordinates and a GeoJSON LineString, or paste a list of "lat, lng" points to encode them. Choose precision 6 for the higher-precision variant some services (and OSRM/Valhalla) use.

One thing to watch: a polyline stores coordinates in latitude, longitude order — the opposite of GeoJSON, which uses longitude, latitude. This tool keeps that straight, showing decoded points as lat/lng and emitting correctly-ordered GeoJSON. Precision must match how the string was created — decoding a precision-6 polyline as precision 5 puts the points in the wrong place — so if a route looks off by a factor of ten, switch the precision. Everything is computed on your device; no coordinates are uploaded.

Frequently asked questions

What is a Google encoded polyline?

A compact ASCII string that represents a series of latitude/longitude points, defined by Google's Encoded Polyline Algorithm. It's what the Google Maps Directions API returns for a route's path, and it's widely supported by mapping libraries because it's much shorter than a list of raw coordinates.

How do I decode a polyline to coordinates?

Paste the encoded string into the decoder and it outputs the list of latitude/longitude points, plus a GeoJSON LineString you can drop into a map. Make sure the precision matches how it was encoded (5 for Google's default).

What is the difference between precision 5 and 6?

Precision is how many decimal places of latitude/longitude are preserved: precision 5 (Google's default) keeps about 1-metre resolution, precision 6 keeps about 10 cm and is used by some routing engines like OSRM and Valhalla. The two aren't interchangeable — decode with the same precision the string was encoded at.

Why are my decoded points in the wrong place?

Usually a precision mismatch (try switching between 5 and 6), or a latitude/longitude order mix-up. Polylines are latitude-first; GeoJSON and many map APIs are longitude-first. This tool labels the order to avoid the confusion.

Does it output GeoJSON?

Yes — decoding produces a GeoJSON LineString with the coordinates correctly reordered to longitude, latitude, ready to paste into Leaflet, Mapbox or any GeoJSON tool.

Are my coordinates uploaded?

No — encoding and decoding run entirely in your browser and nothing is transmitted, so location data stays on your device. It works offline too.

Related file converters

From the blog