Coordinates in
One point per line, as latitude, longitude
Encoded polyline out
3 points · precision 5
This follows Google's published encoded polyline algorithm — the same format returned by the Directions and Routes APIs. Everything runs in your browser; nothing is sent to a server. A precision-5 string cannot be decoded correctly at precision 6 (and the other way round), so store the precision alongside the string.
Runs entirely in your browser — your inputs never leave this page.
How this tool works
- 1
Paste one point per line as "lat, lng" to encode, or paste an encoded string to decode. Encoding follows Google’s published algorithm: scale by 10^precision, store the difference from the previous point, zig-zag negative values, and emit 5-bit chunks shifted into printable characters.
- 2
Pick precision 5 for the classic Google Maps format, or 6 if your data came from a routing engine that uses the finer scale — the two are not interchangeable.
- 3
Both directions are drawn on the map as you type, so a swapped latitude and longitude or a wrong precision shows up immediately as a route in the wrong place.
Common uses
- Storing a GPS track or delivery route as one short string in a database or URL
- Debugging encoded polylines returned by the Google Directions or Routes APIs
- Moving routes between mapping libraries that expect different precision
Frequently asked questions
A compact text format Google designed for paths on a map. A route that would take hundreds of characters as raw coordinates fits in a short string, which is why the Directions and Routes APIs return routes this way.
More in Developer Tools
- Tile XYZ CalculatorConvert between latitude/longitude, zoom levels, and standard slippy map tile coordinates (X, Y, Z). Calculate geographic bounding boxes and URL patterns.
- QuadKey ConverterConvert between Microsoft Bing Maps QuadKey hierarchical spatial indexing strings and standard XYZ tile numbers or Lat/Lng coordinates.
- API PlaygroundInteractive API console to test serverless geocoding, geodesic distance matrices, elevation profiles, and time zone endpoints with copyable cURL and JSON payloads.
- Map Embed GeneratorGenerate clean, fast-loading, responsive HTML iframe embed snippets for interactive maps to embed in websites and blogs.
- Tile Coordinate CalculatorConvert latitude and longitude coordinates into Slippy Map tile numbers (X, Y, Zoom level) and compute geographic bounding boxes.
- QuadKey ConverterConvert Slippy Map XYZ coordinates to Bing Maps QuadKey hierarchical spatial indices and back with visual quadtree breakdown.
- GeoJSON ValidatorPaste or drop a GeoJSON file to validate it against RFC 7946. Get pinpointed errors, one-click fixes for unclosed rings and winding order, and a clean download.
- US Address GeneratorGenerate random US test addresses with a real city, state and ZIP code pairing. Pick a state, choose how many you need, and copy realistic placeholder addresses for form testing, QA and demos — each with approximate map coordinates.
- UK Address GeneratorGenerate random UK test addresses with a real town, county and postcode district. Choose a town, pick how many you need, and copy correctly formatted placeholder addresses for form testing, QA and demos.
- US Phone GeneratorGenerate random US test phone numbers with real area codes for real cities — but always in the reserved fictional 555-0100 to 555-0199 range, so a generated number can never belong to a real person. Built for form testing, QA and demos.
- Photo GPS EditorSee the GPS location stored inside a JPEG photo, move it to the right place, or strip it out before you share the picture. Everything happens in your browser — your photo is never uploaded.
Encoding a Two-Stop GPS Route in Northern California, Checked by Hand
Tom is a developer in Sacramento, California, building a small route-planning app for a local delivery firm. A driver's GPS logger exports raw waypoints, and the first test file holds just two points: 38.5, -120.2 in the Sierra foothills, and 40.7, -120.95 further north. Storing every route as long lists of decimal coordinates makes his database rows and share links unwieldy, and the mapping API he calls wants routes in Google's encoded polyline format anyway. So he runs the two points through the polyline encoder at the standard precision of 5 — and before trusting it, he checks the first values by hand against the published algorithm.
The hand check goes like this. Each coordinate is multiplied by 100,000, so 38.5 becomes 3,850,000 and -120.2 becomes -12,020,000. Only differences are stored: the first point is measured from zero, and negative differences are zig-zag folded — doubled and flipped — so -12,020,000 is carried as 24,039,999. Each folded number is then sliced into 5-bit chunks, every chunk is shifted by 63 into the printable character range, and the chunks are written smallest-first. The latitude of the first point comes out as _p~iF and its longitude as ~ps|U. The second point stores only its change from the first — latitude up 2.2 degrees (220,000 after scaling) and longitude down 0.75 (a folded -75,000) — which encodes as _ulLnnqC. Joined together, the whole route is the single string _p~iF~ps|U_ulLnnqC.
Tom verifies the result two ways. First, he decodes the string in the same tool and gets back exactly 38.5, -120.2 and 40.7, -120.95, with the preview line sitting in northern California where the drive actually happened. Second, he compares with Google's own documentation, which uses these same points as its worked example: adding the documented third point, 43.252, -126.453, extends the string to _p~iF~ps|U_ulLnnqC_mqNvxq`@ — a match. He also notes what changes at precision 6: the same two points produce _izlhA~rlgdF_{geC~ywl@, a completely different string, so his database stores the precision next to every route.
With the format proven, Tom saves the encoded string in one database column instead of a table of coordinate rows, and route links shrink from hundreds of characters to a short parameter. He stays clear about the limits, though. Encoding at precision 5 rounds each point to five decimal places — about 1.1 metres — which is fine for a delivery route but not for survey work. And an encoded polyline is compression, not secrecy: anyone who pastes the string into a decoder sees the route. The original coordinates stay in his export file as the source of truth, and the string is just the compact travelling copy.
Common mistakes to avoid
- Decoding at the wrong precision. A precision-5 string decoded at precision 6 (or the other way round) returns coordinates that are ten times too large or too small — routes land in the ocean or on the wrong continent. Precision is part of the data: store it with the string and decode with the same setting.
- Swapping latitude and longitude. The format always stores latitude first. Encode a list written as 'lng, lat' and every point is mirrored across the map's diagonal — a California route appears in the southern ocean. If a decoded route looks like a reflection of the real one, the order is the first suspect.
- Losing characters when copying the string. Encoded strings legitimately contain characters like ` and @, and the final chunk of a value can look like punctuation a spreadsheet or shell quietly eats. A single dropped character corrupts everything after it. Copy the string whole, and prefer the copy button over retyping.
Pro tips
- Keep the raw coordinate list as your source of truth and treat the encoded string as a transport copy you can regenerate.
- After decoding an unfamiliar string, look at the map preview before using the numbers — a wrong precision or swapped order is obvious at a glance.
- For short test routes, compare your encoder's output with Google's documented example points (38.5, -120.2 and friends) — a match proves the implementation, not just the input.
Applied Geospatial: Aviation, Marine, Time & Map APIs
Where mapping meets the real world: how planes navigate the curve of the Earth, how ships measure the sea, how time zones really work, and how developers build on map tiles and APIs. Written for Encoded Polyline Encoder & Decoder — Google Polyline Algorithm and the everyday mapping tasks around it.
Great-Circle Navigation: Why Planes Arc
The shortest path between two points on a sphere is a great circle — the route you get slicing the planet through its center. On a flat map this looks like a dramatic arc, which is why New York to Tokyo flights swing near Alaska. The map is lying; the plane is flying straight.
Airlines do not fly perfect great circles. Jet streams — rivers of wind at 35,000 feet — can add 100 mph to ground speed or subtract it. Dispatchers nudge routes into favorable winds, trading a few extra miles for much faster trips. The planned track is a great circle bent by the weather.
For flight planning, distances come in flavors. Great-circle miles are the geometric minimum; filed flight plans run 3 to 7 percent longer for airways and maneuvering. Fuel planning adds reserves on top. When a tool reports 5,500 miles for a transatlantic hop, the airline plans for 5,800.
Airports are identified by two code systems. The 3-letter IATA codes (JFK, LHR, CDG) are for travelers; the 4-letter ICAO codes (KJFK, EGLL, LFPG) are for pilots and air traffic control, with the first letter naming the region. Both point to the same runways.
At Sea: Nautical Miles, Knots & Rhumb Lines
A nautical mile is one minute of latitude — about 1.15 land miles or 1.85 kilometers. Because it derives from the Earth's geometry, it is the natural unit for marine navigation: one minute of latitude traveled equals one nautical mile made good, anywhere on the planet.
Speed at sea is measured in knots — nautical miles per hour. The word comes from sailors tossing a knotted rope overboard and counting knots paid out against a sandglass. A container ship at 20 knots covers about 480 nautical miles a day, which is why your overseas order takes weeks.
Sailors historically steered rhumb lines: courses of constant compass bearing. A rhumb line spirals toward the pole and runs longer than the great circle, but it is trivially easy to follow — just hold the heading. Modern ships with GPS follow great circles, but the rhumb line remains the backup every navigator learns.
Ports are the fixed points of maritime geography. Each major harbor publishes exact coordinates for its harbor entrance, and shipping contracts price by port pair. A few miles of error in a port position can misroute a vessel into the wrong traffic lane — precision matters even on the open ocean.
This page shows the first two chapters. Read the complete this category field guide →