Polyline Decoder & Encoder

Decode a Google encoded polyline into coordinates and GeoJSON, or encode a list of coordinates into a polyline string. Used by the Google Maps, OSRM and Valhalla routing APIs.

About encoded polylines

The encoded polyline algorithm compresses a series of coordinates into a short ASCII string. Google Maps Directions, OSRM, Valhalla, Mapbox and many routing APIs return route geometry this way. Decoding it by hand is painful; this tool does it instantly and also gives you ready-to-use GeoJSON.

How to use it

  1. Paste the polyline from your API response and click Decode.
  2. Or paste "lat, lon" lines and click Encode to polyline.
  3. Pick precision 6 if your string comes from Valhalla or OSRM's polyline6 format.

Frequently asked questions

My decoded route looks scaled wrong. Why?

Precision mismatch. A polyline6 string decoded at precision 5 lands 10 times off. Switch the precision setting and decode again.

What coordinate order is the output?

The coordinate list shows "lat, lon" per line. The GeoJSON output uses [lon, lat], as GeoJSON requires.

Do backslashes in JSON responses matter?

Yes. If you copied the polyline from raw JSON, unescape it first: \\ becomes \.