How the GPX to GeoJSON Converter works, and what it assumes
GPX (GPS Exchange Format) is the XML file almost every GPS device and fitness app can export: Garmin Connect, Strava, Komoot, OsmAnd, Wikiloc and handheld units all write it. It is built for journeys rather than maps, which is why converting it well means keeping more than the lines. The converter reads the GPX's XML, turns each waypoint, route and track into a GeoJSON Feature, and writes an RFC 7946 FeatureCollection. GPX, like GeoJSON, is always WGS 84 latitude and longitude, so no coordinate is reprojected.
Tracks, routes and waypoints
The three are different things and stay separate. A track (<trk>) is the path you actually
took, recorded point by point, usually with a time on every point. A route (<rte>) is a plan: a
few turn points a device navigates between. A waypoint (<wpt>) is one named place, such as
a trailhead or a water stop. Tracks and routes become LineStrings and waypoints become Points, each with a
_gpxType property of trk, rte or wpt. A track recorded in
several segments, because it was paused or lost signal, becomes a MultiLineString, so no straight line is drawn
across the gap. Untick any of the three under Include to leave it out.
Elevation and time
Elevation from <ele> becomes the third number of each position. It is kept only when every
point of a line has one, because a line that mixes 2D and 3D positions breaks most software. Timestamps go into
coordinateProperties.times, one per position, the layout the widely used togeojson library writes.
Heart rate, cadence, temperature and power from Garmin's TrackPointExtension come along the same way, so a
notebook can still compute pace or heart-rate zones from the GeoJSON.
How your data is handled
A GPS track shows where you live, work and train, so it is converted entirely on your device and never uploaded. The map preview has no basemap until you switch it on. Have another format? Use the KML to GeoJSON converter for Google Earth files or the Shapefile to GeoJSON converter for GIS layers. To measure between two points of a track use the Distance Calculator, and to store the result in a spatial database convert it with GeoJSON to WKT.
Where this comes up in GIS work
- Drawing a ride, run or hike on a Leaflet or Mapbox map for a blog post or a club website.
- Loading recorded tracks into PostGIS or a Python notebook to measure distance, speed or elevation gain.
- Turning waypoints collected in the field with a handheld GPS into a point layer for QGIS.
- Comparing a planned route with the track that was actually recorded, as two features in one file.
A worked example
The first two points of a recorded bike ride, with elevation and time:
<trk><name>Morning ride</name>
<trkseg>
<trkpt lat="12.98300" lon="77.62000"><ele>897.2</ele><time>2024-05-01T06:00:00Z</time></trkpt>
<trkpt lat="12.98412" lon="77.62071"><ele>898.0</ele><time>2024-05-01T06:00:30Z</time></trkpt>
</trkseg>
</trk>
becomes:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"_gpxType": "trk",
"name": "Morning ride",
"time": "2024-05-01T06:00:00Z",
"coordinateProperties": {
"times": [
"2024-05-01T06:00:00Z",
"2024-05-01T06:00:30Z"
]
}
},
"geometry": {
"type": "LineString",
"coordinates": [
[77.62, 12.983, 897.2],
[77.62071, 12.98412, 898]
]
}
}
]
}
GPX writes latitude first as attributes; GeoJSON writes longitude first, so the order flips. Elevation becomes the third coordinate, and trailing zeros such as 12.98300 are not kept, because they carry no precision.
Using the GPX to GeoJSON Converter
- Export the activity or route as GPX (on Strava: the activity's menu, Export GPX; on Garmin Connect: the gear icon, Export to GPX).
- Drop the .gpx file on the upload box, choose Choose file, or paste the GPX text. Load example opens a short bike ride.
- Untick Waypoints, Routes or Tracks under Include if you only want some of them.
- Check the summary and the map, then choose 5 to 8 decimal places; 6 is about 11 cm, finer than any phone GPS.
- Copy or download the GeoJSON, or open it in the Geometry Viewer or GeoJSON to WKT.
When the output looks wrong
- Line 12: invalid coordinate in <trkpt>: lat="" lon="77.59"
- Every point needs lat and lon attributes in decimal degrees. Some apps write empty values when the GPS had no fix; delete those points in a text editor, or re-export the activity, and convert again.
- Some tracks came out without elevation
- A line keeps elevation only when every one of its points has an <ele>. Mixing 2D and 3D positions in one line is legal GeoJSON that most software mishandles, so the tool drops elevation for that line and says so in the notes.
- My track is a MultiLineString, not a LineString
- The track has several <trkseg> segments, usually because the recording was paused or lost signal. Each segment is kept as a separate line so no straight jump is drawn across the gap; the times follow the same structure.
Questions about the GPX to GeoJSON Converter
What is the difference between a GPX track, route and waypoint?
A track (trk) is where you actually went, recorded point by point with times. A route (rte) is a planned path of turn points, usually without times. A waypoint (wpt) is a single named place. Each becomes its own feature, and the _gpxType property says which it was.
Are elevation and time kept?
Yes. Elevation from <ele> becomes the third number of each position, as RFC 7946 allows. Point times go in coordinateProperties.times, one per position, and a track also gets a time property with its first timestamp. That is the layout the widely used togeojson library writes, so existing code keeps working.
Does it keep heart rate and cadence from Garmin or Strava files?
Yes, when the file has them. Garmin TrackPointExtension values for heart rate, cadence, temperature and power are collected into coordinateProperties as heartRates, cadences, atemps and powers, lined up with the positions; points without a value get null.
Why is my GPX track in the wrong place?
It almost never is: GPX is always WGS 84 latitude and longitude, like GeoJSON. If the line looks wrong, check for points with a zero or missing fix, which appear as a spike to 0, 0 off the coast of Africa, and delete them from the GPX.
Can I convert several GPX files at once?
One file at a time, so each result keeps its own name and summary. Convert each file in turn and download it; merging FeatureCollections afterwards is a simple concatenation of their features arrays.
Is my GPS data uploaded?
No. A GPX track shows where you live, work and train, so this matters: the file is read and converted in your browser and never sent to our server. The optional basemap only requests map tiles, and it is off unless you switch it on.