Polyline Encoder / Decoder

Encode coordinates into a Google polyline string or decode one back to lat/lng and GeoJSON, right in your browser. Your route stays on your device.

The coordinates and polyline strings you paste are encoded and decoded locally in your browser and are never uploaded; nothing you enter is stored on a server.

Want to see the route on a map? Open the Coordinate Map Viewer.

About Polyline Encoder & Decoder

This polyline encoder and decoder handles Google's Encoded Polyline Algorithm Format entirely in your browser. In Encode mode, paste one "lat, lng" per line — or a GeoJSON LineString — and get the compact encoded string that Directions APIs return for a route. In Decode mode, paste an encoded polyline and read back the coordinate list plus a ready-to-use GeoJSON LineString you can drop into a map. A precision toggle switches between 5 (the Google Maps default) and 6 (used by OSRM, Valhalla and Mapbox), which is the usual reason a decoded route lands in the wrong place. Polylines pack a whole path into a short ASCII string, so this is handy when an API hands you an encoded route and you need plain coordinates, or vice versa. Everything is computed on your device and the route you paste is never uploaded.

Features

How to use the Polyline Encoder & Decoder

  1. Choose Encode to turn coordinates into a polyline, or Decode to expand one.
  2. Pick precision 5 (Google) or 6 (OSRM/Valhalla) to match your data source.
  3. Paste coordinates (one "lat, lng" per line or a GeoJSON LineString), or an encoded polyline.
  4. Read the encoded string, or the coordinate list and GeoJSON LineString, in the results.
  5. Copy any output for your map, API request, or data file.

Example

Input

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

Output

_p~iF~ps|U_ulLnnqC_mqNvxq`@

The canonical three-point route from Google's docs, encoded at precision 5.

Common errors & troubleshooting

Frequently asked questions

What is a Google encoded polyline?
It is a compact ASCII encoding of a path of latitude/longitude points, defined by Google's Encoded Polyline Algorithm Format. Directions and Roads APIs return routes this way because the string is far shorter than a full list of coordinates, and it decodes back to the exact points.
Should I use precision 5 or 6 for my polyline?
Use 5 for Google Maps and the Google Directions API, and 6 for OSRM, Valhalla, GraphHopper and Mapbox. Precision 6 keeps one extra decimal, so a string encoded at 6 but decoded at 5 lands roughly ten times off — always match the tool that created the polyline.
How do I convert an encoded polyline to GeoJSON?
Switch to Decode, paste the polyline, and the tool outputs a GeoJSON LineString Feature alongside the plain coordinate list. The GeoJSON already uses [longitude, latitude] order, so you can paste it straight into geojson.io, Leaflet or a mapping library.
Can I encode a GeoJSON LineString into a polyline?
Yes. In Encode mode you can paste a GeoJSON LineString, or a Feature or FeatureCollection wrapping one, and the tool reads its coordinates and returns the encoded string. You can also paste plain "lat, lng" lines if you do not have GeoJSON.
Is my route data sent anywhere when I encode or decode it?
No. The encoding and decoding run entirely in your browser using the standard algorithm, so the coordinates and polylines you paste are processed on your device and are never uploaded to a server.

Related tools

All ArrayKit tools