KML to GPX: How to Convert It and What Gets Lost

By the Places Export editorial team · · 7 min read

To convert KML to GPX, each KML placemark is rewritten as its GPX equivalent: points become waypoints (<wpt>), and lines become tracks or routes. The most dependable free way is GPSBabel, an open-source converter: gpsbabel -i kml -f input.kml -o gpx -F output.gpx. If your file is a KMZ, unzip it first, and expect styles, folders and shapes to be dropped, because GPX has no place to put them.

KML and GPX in brief

KML, formerly Keyhole Markup Language, was developed by Google and submitted to the Open Geospatial Consortium (OGC), which adopted version 2.2 as an implementation standard. OGC describes it as an XML language for geographic visualization, including the annotation of maps and images. A KML file says what to draw and how to draw it: placemarks with points, lines and polygons, icon and line styles, folders, and descriptions that can contain HTML.

GPX, the GPS Exchange Format, is a lightweight XML format for moving GPS data between programs and devices. TopoGrafix, which maintains it, calls it the de facto standard for this since GPX 1.0 came out in 2002. The current schema, GPX 1.1, holds three kinds of data: waypoints, routes and tracks. All coordinates use the WGS84 datum in decimal degrees, and measurements are metric.

Put simply, KML describes how a map should look, and GPX describes where things are so a device can use them. That's why the conversion is mostly about keeping the positions and names and letting the styling go.

How KML maps onto GPX

In KMLIn GPXNotes
Placemark with a <Point><wpt> (waypoint)The usual case for saved places and points of interest
Placemark with a <LineString><trk> with <trkseg> and <trkpt>, or <rte> with <rtept>Which one you want depends on the app or device
<name><name>Carries over directly
<description><desc>GPX text is plain; HTML markup may come through as raw tags or be stripped, depending on the tool
Altitude in <coordinates><ele>Only if the converter fills it; check the output
<Polygon>NothingGPX has no area type
<Style>, icons, colorsNothingGPX can carry extras only as custom extensions
<Folder>NothingA GPX file is flat lists of waypoints, routes and tracks

Watch the coordinate order

This is the classic conversion bug. In KML, a point's position is written as text in the order longitude, latitude, then an optional altitude, separated by commas. In GPX, latitude and longitude are separate attributes, lat and lon. The GPX schema allows latitude from -90 to 90 and longitude from -180 up to (but not including) 180. For places in the US, a swapped file is often invalid outright, because a longitude like -104.99 can't be a latitude.

Example: the same place in both formats

Here is one placemark in KML:

<Placemark>
  <name>Trailhead parking</name>
  <description>Lot fills by 8 a.m. on weekends</description>
  <Point>
    <coordinates>-105.2705,40.0150</coordinates>
  </Point>
</Placemark>

And the same place as a complete GPX 1.1 file:

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="hand-edited" xmlns="http://www.topografix.com/GPX/1/1">
  <wpt lat="40.0150" lon="-105.2705">
    <name>Trailhead parking</name>
    <desc>Lot fills by 8 a.m. on weekends</desc>
  </wpt>
</gpx>

Notice that the two numbers swap places, and that GPX needs a version and a creator on its root element, both required by the schema.

Method 1: convert with GPSBabel

GPSBabel is free software released under the GNU Public License, and its site says it runs on Windows 10 and 11, macOS and Linux. It reads and writes KML, including waypoints, tracks and routes.

  1. Download GPSBabel from gpsbabel.org and install it.
  2. If you have a .kmz file, unpack it. Google's KML documentation explains that a KMZ is a Zip archive with one main KML file (usually named doc.kml) plus supporting files such as icons. Make a copy, rename it from .kmz to .zip, extract it, and find the .kml file at the top level.
  3. Open a terminal in that folder and run: gpsbabel -i kml -f input.kml -o gpx -F output.gpx Here -i and -f name the input format and file, and -o and -F name the output format and file.
  4. Open output.gpx in a text editor or your GPS app and check that the number of waypoints and tracks matches what you expected.

GPSBabel's own documentation is candid about its limits: simple files with waypoints and paths convert fine, but handcrafted KML with nested folders, camera angles or styles may give unexpected results. If that happens, simplify the file first, or split it into one file per folder.

Method 2: convert a few points by hand

For five or ten places, a text editor is enough:

  1. Start with the GPX wrapper from the example above.
  2. For each <Placemark>, add a <wpt> with lat and lon taken from the KML coordinates, remembering to swap their order.
  3. Copy <name>, and copy <description> into <desc> as plain text.
  4. Save the file with a .gpx extension and test it in your app.

If your KML came from Google Maps saved places

Many KML files people want to convert are their own Google Maps saved places. In that case you can skip KML entirely. Places Export reads the Google Takeout export of your saved lists and writes GPX directly, with each place as a waypoint carrying its name, a description (address and notes) and a link back to Google Maps. It runs in your browser, nothing is uploaded, and it's an independent tool, not affiliated with Google. Our Google Maps to GPX guide covers the whole process, including routes built in My Maps.

Going the other way is useful to know too. Google's Earth documentation says Google Earth on the web doesn't import GPX directly and suggests converting GPX to KML or CSV first, while the desktop Google Earth Pro can import GPS data saved as .gpx.

Common mistakes

  • Feeding a KMZ to a tool that expects KML. Unzip it first and convert the .kml inside.
  • Swapped coordinates. Points end up in the ocean, or the file fails to load. Compare one point against a map before converting the rest.
  • Expecting polygons to survive. A park boundary or delivery zone has no GPX equivalent. Keep the KML for those.
  • Choosing waypoints when your app wants a track, or the reverse. Saved places belong as waypoints; a path you plan to follow is usually a track or a route. Check what your device imports.
  • Losing notes inside HTML. Rich KML descriptions can turn into a wall of tags in a GPX <desc>. Clean them up before or after converting.
  • A KMZ with several KML files inside. Google's KMZ guidance calls for a single top-level .kml, and Google Earth opens the first one it finds. If yours has more, convert each one.

FAQ

Is GPX better than KML?

Neither is better; they do different jobs. KML is built for displaying and styling data in Earth browsers and map tools. GPX is built for exchanging waypoints, routes and tracks with GPS devices and outdoor apps.

Can I convert KMZ to GPX directly?

Unzip the KMZ first and convert the KML file inside. A KMZ is just a Zip archive around a main KML file.

Will elevation carry over?

KML altitude is optional, and GPX has an <ele> element for elevation. Whether it's filled depends on the converter and on whether your KML had altitudes at all, so check a few points in the output.

Can Google Earth open GPX files?

Google Earth Pro on desktop can import GPS data from .gpx files. Google Earth on the web can't import GPX directly; Google suggests converting it to KML or CSV first.

Sources