Google Polyline Decoder

Decode a Google encoded polyline string into lat/long points

Ad placeholder (leaderboard)

Decoding a polyline

Routing and mapping APIs return paths as a single encoded polyline string to save bandwidth. This tool turns that string back into the list of coordinates so you can plot, inspect or process the route yourself.

How it works

The decoder walks the string character by character. It subtracts 63 from each character, strips the continuation bit (0x20), and accumulates 5 bit chunks until a chunk without the continuation bit ends the value. That signed integer is the delta from the previous coordinate; it is un-shifted and inverted if odd to recover the sign.

_p~iF~ps|U_ulLnnqC_mqNvxq`@
  ->  38.5, -120.2 / 40.7, -120.95 / 43.252, -126.453

Latitude and longitude alternate, and each running total is divided by ten to the precision to produce the final coordinate.

Example and tips

If the decoded points land in the ocean or far from where you expect, the precision is almost certainly wrong, so toggle between 5 and 6. The values are returned in path order, exactly as encoded. Because the format is lossy at the chosen precision, decoding then re-encoding may differ by a unit in the last decimal place, which is normal.

Ad placeholder (rectangle)