GPX File Documentation


Summary

A GPS Exchange File stores GPS data (waypoints, routes and recorded tracks) as plain UTF-8 XML, and is the standard way to move routes between apps and devices like Garmin, Strava and Komoot. Its MIME type is application/gpx+xml and the extension is .gpx. Because it is text built on a published schema, any text editor opens it, and mapping tools read the coordinates, timestamps and elevations directly.

Technical details

FeatureValue
Full nameGPS Exchange Format
File extension.gpx
MIME typeapplication/gpx+xml
Format typeXML text (GPS data)
Base formatXML 1.0, UTF-8
DeveloperTopoGrafix (Dan Foster)
IntroducedGPX 1.0 in 2002; GPX 1.1 in 2004 (current)
Namespacehttp://www.topografix.com/GPX/1/1
SchemaW3C XML Schema (gpx.xsd)
Root element<gpx> with version and creator attributes
Data objectsWaypoints <wpt>, routes <rte>, tracks <trk>
Coordinate systemWGS 84 decimal degrees; elevation in metres
TimestampsISO 8601 UTC (<time>)
Extensibility<extensions> element (e.g. Garmin heart rate, cadence)
Signature (magic bytes)None — begins with <?xml then <gpx>
Open standardYes — free, royalty-free schema
Related extensions.kml, .kmz, .fit, .tcx, .geojson
Specificationtopografix.com/gpx.asp
Structure at a glance

A .gpx is UTF-8 XML with no binary signature. It opens with <?xml version="1.0"?> and a single <gpx> root carrying version="1.1", a creator attribute naming the app that wrote it, and the TopoGrafix namespace http://www.topografix.com/GPX/1/1. Inside are three kinds of geographic object: <wpt> waypoints (single points), <rte> routes (points to navigate) and <trk> tracks (a recorded trail of <trkpt> points). Coordinates are WGS 84 decimal degrees in lat and lon attributes.

What is a GPX file?

GPX stands for the GPS Exchange Format, an open XML schema for moving GPS data between programs and devices. It was published by TopoGrafix (Dan Foster): version 1.0 in 2002 and the still-current version 1.1 in 2004, released as a free, royalty-free schema anyone can implement. That openness is why GPX became the common tongue of the outdoor, fitness and mapping world: Strava, Komoot, Garmin Connect, AllTrails, Wikiloc, OpenStreetMap editors and virtually every GPS watch and bike computer can read and write it.

A GPX file is plain UTF-8 XML that carries three kinds of geographic object: waypoints (single named points), routes (an ordered list of points to navigate between) and tracks (a recorded breadcrumb trail of where a device actually went, usually time-stamped and often with elevation). Everything below describes the actual element tree, the coordinate and time conventions, and the extension mechanism that lets Garmin and others carry heart-rate and cadence data GPX does not model natively. (Note: a completely different .gpx file is a Guitar Pro music archive; this page is the GPS format.)

The gpx root: version, creator and namespace

Every GPX file has one <gpx> root element, and its attributes matter for parsing.

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1"
     creator="StravaGPX"
     xmlns="http://www.topografix.com/GPX/1/1"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.topografix.com/GPX/1/1
                         http://www.topografix.com/GPX/1/1/gpx.xsd">
  ...
</gpx>

The version attribute is 1.1 for current files (older ones say 1.0, and the two schemas differ), and creator is a free-text string naming the app or device that produced the file, which is often the quickest way to tell where a track came from. The default xmlns declares the TopoGrafix 1.1 namespace; this, not any byte signature, is what identifies a file as GPS-Exchange GPX. The schemaLocation points at gpx.xsd, the W3C XML Schema that formally defines every allowed element and its data type, so a validator can check a GPX file against it. An optional <metadata> block can follow, holding the file’s name, description, author, a <time> and a <bounds> box of min/max latitude and longitude.

Waypoints, routes and tracks: three ways to hold points

The three top-level data objects all describe points on the Earth, but they mean different things.

<gpx>
 ├─ <wpt lat lon>         a single standalone point of interest
 ├─ <rte>                 a route (to be navigated)
 │   └─ <rtept lat lon>   ordered route points
 └─ <trk>                 a track (a recorded trail)
     └─ <trkseg>          a contiguous segment (GPS fix not lost)
         └─ <trkpt lat lon>  recorded track points, usually time-stamped

A waypoint (<wpt>) is one location: a summit, a trailhead, a parked car. A route (<rte>) is a planned path, an ordered set of <rtept> points a device navigates between, typically sparse. A track (<trk>) is what a recording produces: a dense list of <trkpt> points logged as you moved, grouped into one or more <trkseg> segments. The segment boundary is meaningful: a new <trkseg> marks a break in continuous recording, such as a lost GPS fix or a paused activity, so points inside one segment should be joined by lines but points across a segment gap should not. The practical difference between a route and a track is planned-versus-actual: a route is where you intend to go, a track is where you went.

Inside a track point: coordinates, elevation and time

The atom of a GPX file is the point element. Latitude and longitude are XML attributes; everything else is a child element.

<trkpt lat="47.644548" lon="-122.326897">
  <ele>4.46</ele>
  <time>2024-03-12T08:31:05Z</time>
</trkpt>

The lat and lon attributes are decimal degrees in the WGS 84 datum, the same reference system the Global Positioning System uses, with latitude in the range −90 to +90 and longitude −180 to +180. Positive is north and east; negative is south and west. The child <ele> is elevation in metres above the WGS 84 ellipsoid. The child <time> is an ISO 8601 timestamp in UTC, marked by the trailing Z; recording it lets tools compute speed and pace by differencing consecutive points. Because latitude and longitude are attributes rather than element text, a common parsing mistake is to look for them as child elements and find nothing. GPX carries no coordinate system choice: it is always WGS 84 decimal degrees, which is what makes files from different vendors directly comparable.

The extensions element: heart rate, cadence and vendor data

Standard GPX 1.1 models only location, elevation and time. It has no native field for heart rate, cadence, power or temperature. To carry that data without breaking the schema, GPX defines an <extensions> element that may appear inside a point (or a track), into which vendors put their own namespaced elements.

<trkpt lat="47.6" lon="-122.3">
  <ele>12.0</ele>
  <time>2024-03-12T08:31:05Z</time>
  <extensions>
    <gpxtpx:TrackPointExtension>
      <gpxtpx:hr>146</gpxtpx:hr>
      <gpxtpx:cad>88</gpxtpx:cad>
    </gpxtpx:TrackPointExtension>
  </extensions>
</trkpt>

Here gpxtpx is Garmin’s TrackPointExtension namespace, carrying heart rate (hr) and cadence (cad). Because these live under <extensions> in their own namespace, a reader that does not understand them ignores them and still parses the location data cleanly, which is the whole point of the mechanism. It also explains why a GPX exported from one platform can arrive at another with no heart-rate data: if the source did not write the extension, or the target does not read that vendor’s namespace, the fields are simply absent. When full fitness metrics must survive, people export Garmin’s binary .fit or the XML .tcx instead, which model those channels natively.

GPX next to KML and GeoJSON

GPX is one of several ways to store geographic data as text, and the differences are about purpose. KML (and its zipped form KMZ) is Google’s XML format for Google Earth and Maps; it carries far richer styling, icons, overlays and 3D, which is why converting GPX to KML is common when the goal is a good-looking map rather than a device-loadable route. GeoJSON is the JSON format the web-mapping stack (Leaflet, Mapbox) expects, and represents the same points and lines as JSON geometry. GPX is narrower and more device-focused: it models exactly waypoints, routes and tracks with time and elevation, which is precisely the vocabulary a GPS watch or bike computer needs, and no more. That focus is why it, rather than KML, is the format outdoor and fitness devices import and export.

Coordinates as a privacy concern

A GPX file is plain XML with no executable content, so opening one is harmless to your computer. The real risk is informational: a track records exact coordinates and timestamps, so a shared file can reveal a home address, a regular commute, or when a house is empty. The start and end points of a recorded ride or run are the sensitive ones, because they usually sit at the door. Before sharing GPX publicly, trim the points near home (many apps have a privacy-zone feature that does this) and, if your schedule is sensitive, strip the <time> elements, since removing them leaves the shape of the route without disclosing when you were there.

Frequently asked questions

What is the difference between GPX and KML?

GPX is the open GPS-exchange standard used by fitness and outdoor apps and devices, and models waypoints, routes and tracks with time and elevation. KML is Google’s format for Google Earth and Maps, with much richer styling and 3D. They convert back and forth easily because both are XML describing points and lines.

Why does my GPX have no heart rate or power?

Standard GPX only stores location, elevation and time. Heart rate, cadence and power are carried in vendor-specific elements under <extensions>, so they are present only if the exporting app wrote them and the reading app understands that namespace. Export to Garmin’s .fit or .tcx if you need those channels reliably.

What does a new track segment mean?

A <trkseg> boundary marks a break in continuous recording, typically a lost GPS fix or a paused activity. Points within a segment are meant to be connected by lines; the gap between two segments should not be, which prevents a straight line being drawn across the interruption.

References