Polyline Encoder & Decoder
Encode coordinates into a Google encoded polyline string, or decode one back to latitude/longitude — precision 5 and 6, with GeoJSON output.
What is the Polyline Encoder & Decoder?
The Google encoded polyline algorithm compresses a list of coordinates into a short ASCII string, which is how the Directions API, OSRM, Valhalla and Mapbox return routes.
- Encode and decode in one tool, with a single click to switch
- Precision 5 (Google) and precision 6 (Valhalla, OSRM, Mapbox)
- GeoJSON LineString output with download for either direction
- Detects wrong-precision decodes instead of returning bad coordinates
- Clear errors for truncated strings and out-of-range characters
- 100% client-side — route data is never uploaded
How to use the Polyline Encoder & Decoder
- 1
Choose Encode or Decode, and set the precision to 5 or 6.
- 2
To encode, paste one "latitude, longitude" pair per line.
- 3
To decode, paste the encoded polyline string exactly as your API returned it.
- 4
Copy the result, or download the GeoJSON LineString for mapping.
About the Polyline Encoder & Decoder
The Google encoded polyline algorithm compresses a list of coordinates into a short ASCII string, which is how the Directions API, OSRM, Valhalla and Mapbox return routes. This tool goes both ways: paste coordinates to get the encoded string, or paste an encoded string to get your coordinates back.
Precision is switchable between 5 decimal places (the Google default) and 6 (used by Valhalla, OSRM and Mapbox's polyline6). Decoding at the wrong precision is the classic bug — your route ends up ten times too small or lands off the planet — so the decoder detects impossible coordinates and tells you to switch rather than handing back nonsense.
Every result also comes as a GeoJSON LineString you can drop straight into a map or a test fixture. Encoding and decoding run entirely in your browser, so route geometry from a private API response is never uploaded anywhere.
Frequently asked questions
What is an encoded polyline?
It is a lossy compression of a coordinate list into ASCII text. Each point is stored as a difference from the previous one, scaled to five or six decimals, then written in 5-bit chunks offset by 63. That turns a long route into a compact string that fits in a URL or JSON field.
How do you decode a Google Maps polyline?
Read five bits at a time until you hit a byte without the continuation flag, undo the zig-zag encoding to recover the signed delta, and add it to the running total. Paste your string above and this tool does it, then hands you the coordinates and a GeoJSON LineString.
Why does my decoded polyline land in the wrong place?
Almost always a precision mismatch. Decoding a precision-6 string at precision 5 gives coordinates ten times too large, which usually falls outside ±90° latitude. This decoder detects that and tells you to switch precision.
What is the difference between polyline5 and polyline6?
Only the scaling factor. Precision 5 rounds coordinates to five decimals (about 1.1 m) and is what Google's Directions API returns. Precision 6 keeps six decimals (about 11 cm) and is the default for OSRM, Valhalla and Mapbox's polyline6 format.
Why does my polyline string have backslashes?
The character set includes the backslash, so a raw polyline often contains them. Inside a JSON string or a JavaScript literal each one must be doubled, otherwise the parser eats it and the string decodes to garbage.
Is my route data sent anywhere?
No. Encoding and decoding happen entirely in your browser, so route geometry from a private API response, delivery run or tracked journey is never transmitted or stored.
Related tools
GeoJSON to WKT Converter
Convert GeoJSON to Well-Known Text for PostGIS, Oracle Spatial or SQL Server. Control coordinate precision and merge features into a GEOMETRYCOLLECTION.
WKT to GeoJSON Converter
Convert WKT geometry to GeoJSON in your browser. Supports all seven geometry types, Z and M dimensions, EMPTY geometries and EWKT SRID prefixes.
Distance Calculator
Calculate the straight-line distance and bearing between two points on a map by latitude/longitude using the Haversine formula — km, miles and nautical miles.
Bounding Box Calculator
Calculate the bounding box of a list of coordinates or a GeoJSON file. Get the bbox array, Leaflet bounds, WKT envelope and a downloadable polygon.
GPX to KML Converter
Convert GPX files from your GPS device to KML for Google Earth. Waypoints, tracks and routes preserved with names and elevation — free and private.