GIS · GPS

GPX ↔ GeoJSON Converter

Convert GPX files to GeoJSON and GeoJSON back to GPX. Waypoints, tracks, routes, elevation, and timestamps — all preserved. No data leaves your browser.

Converter
Input

Drag & drop a .gpx or .geojson file, or paste your data directly.

Output
· all processing happens in your browser · no data is sent to any server

What This Tool Does

Bidirectional conversion between GPX (GPS Exchange Format) and GeoJSON — the two most common open formats for GPS and mapping data.

🔄
Both directions
GPX → GeoJSON and GeoJSON → GPX. Switch with one click. The swap button moves the output back to input for round-trip testing.
📍
Waypoints, tracks, routes
GPX waypoints (<wpt>) become GeoJSON Points. Tracks (<trk>) become LineStrings or MultiLineStrings. Routes (<rte>) become LineStrings with route point names preserved.
Timestamps preserved
Track point timestamps (<time>) are stored in a coordTimes array on the GeoJSON feature. On round-trip, these are written back as <time> elements in each <trkpt>.
Elevation preserved
GPX <ele> values become the third coordinate in GeoJSON ([lon, lat, ele]). On reverse conversion, 3-coordinate GeoJSON points write back as GPX <ele> elements.
🗂
Multi-segment tracks
GPX tracks with multiple <trkseg> elements become GeoJSON MultiLineString features. Segment-level timestamps are preserved as a nested coordTimes array.
🔒
100% client-side
All conversion runs in your browser — DOMParser for GPX XML, JSON.parse for GeoJSON. No data is uploaded. Works offline once the page is loaded.

How to Use

1
Choose direction
Click "GPX → GeoJSON" or "GeoJSON → GPX" to set the conversion direction. The input and output panels update their format labels accordingly.
2
Provide input
Paste your GPX or GeoJSON text into the left panel, upload a .gpx, .xml, .geojson, or .json file, or drag-and-drop directly onto the text area. Click "Load sample" to try example data.
3
Convert
Click Convert. The result appears in the right panel with a summary showing how many waypoints, tracks, and routes were processed.
4
Copy or download
Click Copy to copy to clipboard. Click Download to save the file as output.geojson or output.gpx with the correct MIME type.
5
Use your data
Load .geojson in Leaflet, Mapbox, QGIS, or geojson.io. Load .gpx in Garmin devices, Strava, AllTrails, Google Earth, or QGIS.
6
Round-trip conversion
The _gpxType property added to GeoJSON features ('wpt', 'trk', 'rte') helps reconstruct the correct GPX element type on reverse conversion. Use Swap to test both directions.

Logic Behind the Tool

How GPX structures map to GeoJSON features and back.

GPX → GeoJSON element mapping
<wpt>Point feature. Single-segment <trk>LineString. Multi-segment <trk>MultiLineString. <rte>LineString. A _gpxType property ('wpt', 'trk', 'rte') is added to each feature so the original element type can be recovered on reverse conversion.
GeoJSON → GPX element mapping
Point<wpt>. LineString<trk> (or <rte> if _gpxType is 'rte'). MultiLineString → multi-segment <trk>. MultiPoint → multiple <wpt>. Polygons have no GPX equivalent and are skipped.
Coordinate order and elevation
GPX attributes are lat/lon (latitude first). GeoJSON uses [longitude, latitude] (longitude first). The tool correctly maps these without swapping. Elevation is the <ele> element in GPX and the optional third value [lon, lat, ele] in GeoJSON coordinates.
Timestamps and what is lost
Track point <time> values are stored as coordTimes arrays on GeoJSON features — a convention used by Mapbox and other tools. GPX metadata (author, link, bounds, copyright), waypoint links, and track extensions are discarded during conversion. Only geometry, names, descriptions, elevation, and timestamps are preserved.

Frequently Asked Questions

GPX (GPS Exchange Format) is an open XML schema published by TopoGrafix in 2002. It became the standard way to exchange GPS data between devices and software. Every major GPS device brand (Garmin, Magellan, DeLorme), fitness app (Strava, Garmin Connect, Wahoo, AllTrails, Komoot), and mapping platform (Google Earth, OSMand, CalTopo) can export and import GPX. It's the ".mp3 of GPS formats" — not the most efficient, but the most universally compatible.

GeoJSON is the native format for web mapping. Leaflet, Mapbox GL JS, OpenLayers, Turf.js, deck.gl, and most web APIs expect GeoJSON. If you want to display a GPX track on a web map, analyze it with Turf.js, store it in a PostGIS database, or serve it from a REST API — you need GeoJSON. This converter handles the XML parsing and coordinate reordering so you don't have to.

Yes. GPX track point <time> elements are extracted and stored as a coordTimes array property on the GeoJSON feature. This follows the convention used by Mapbox, Turf.js, and other tools for attaching time data to LineString geometries. The array index corresponds to the coordinate array index. If some track points have no timestamp, those positions are stored as null in the array.

Yes. Use L.geoJSON(data).addTo(map) to add the converted GeoJSON to any Leaflet map. Points will appear as markers, LineStrings (tracks and routes) as polylines. For time-based track animation, consider the Leaflet.TimeDimension plugin which understands the coordTimes convention. For Mapbox, the GeoJSON source accepts the output directly.

Each <trk> element in the GPX file becomes a separate GeoJSON Feature in the output FeatureCollection. A track with a single <trkseg> becomes a LineString; a track with multiple segments becomes a MultiLineString. Similarly, each <wpt> and each <rte> becomes its own Feature. The FeatureCollection will contain one feature per GPX element.

Related Tools

View all →

Related Reading