Overview
Introduction
GPX is the XML format GPS devices, fitness apps, and hiking/running trail sites export tracks and routes in, but most mapping tools and geospatial APIs work with GeoJSON. This tool converts between them.
Paste or upload GPX text and get back a pretty-printed GeoJSON FeatureCollection, with tracks, routes, and waypoints all converting, entirely client-side.
What Is GPX to GeoJSON Converter?
A client-side GPX-to-GeoJSON converter built on @tmcw/togeojson's gpx() function, the same library family used by this category's KML converter.
GPX tracks (trk) and routes (rte) become GeoJSON LineString features, each tagged with a _gpxType property so you can tell which was which after conversion, and waypoints (wpt) become GeoJSON Point features.
How GPX to GeoJSON Converter Works
The pasted or uploaded GPX text is parsed into an XML Document with the browser's built-in DOMParser, then checked for a hidden parsererror element before being handed to the gpx() conversion function.
gpx() walks the document's track, route, and waypoint elements and builds one GeoJSON Feature per element, wrapping the result in a single FeatureCollection.
When To Use GPX to GeoJSON Converter
Use this whenever you have a GPX export from a GPS watch, cycling computer, hiking app, or trail-sharing site and need GeoJSON for a web map or geospatial pipeline.
It's also useful for quickly inspecting a GPX file's contents, since GeoJSON's structure is generally easier to skim than GPX's nested track/segment/point XML.
Often used alongside KML to GeoJSON Converter and GeoJSON Viewer.
Features
Advantages
- Runs entirely client-side, your GPS track data never leaves your browser.
- Tracks, routes, and waypoints all convert in one pass, tagged so they stay distinguishable.
- Built on a mature, well-tested conversion library rather than an approximate hand-rolled parser.
Limitations
- Deeply nested per-point metadata (elevation, timestamps) may not fully carry over into GeoJSON's simpler coordinate structure.
- Only accepts plain GPX XML text, there's no support for compressed or bundled GPS-data formats.
Examples
Best Practices & Notes
Best Practices
- Check the _gpxType property on converted line features if you need to separate tracks from routes downstream.
- Verify the feature count after conversion matches the number of tracks, routes, and waypoints you expect in the source file.
- Pipe the output into GeoJSON Viewer to visually confirm the track shape before using it elsewhere.
Developer Notes
`convertGpxToGeoJson` in `gpx-to-geojson-converter.ts` mirrors the KML converter's structure exactly: parse text to a `Document` via `DOMParser`, explicitly check for a `parsererror` element since `DOMParser` never throws, then call `@tmcw/togeojson`'s `gpx(doc)` inside a try/catch so any unexpected conversion failure still resolves to a typed `{success: false, error}` rather than an uncaught exception reaching the component.
GPX to GeoJSON Converter Use Cases
- Converting a GPS watch or fitness app's GPX export to GeoJSON for a web map
- Feeding a hiking or cycling route into a GeoJSON-only geospatial tool or API
- Distinguishing tracks from routes in a converted file via the _gpxType property
Common Mistakes
- Expecting elevation and per-point timestamps to survive conversion in full detail, GeoJSON's coordinate arrays are simpler than GPX's per-point metadata model.
- Mixing up tracks and routes after conversion, check the _gpxType property on each LineString feature rather than assuming based on order.
Tips
- If a large GPX file converts slowly, check whether it contains an unusually dense track (many thousands of trackpoints) before assuming something's wrong.
- Pair with Lat/Lng Point Finder if you need to manually add a reference point alongside a converted track.