GeoJSON vs GPX — Which to Choose?

GeoJSON is a universal web geodata format, GPX is specialized for GPS tracks and routes. GPX is simpler but limited to navigation.

Criteria GeoJSON GPX
Geometry typesAll typesPoints, tracks
GPS devices✗✓
Data attributes✓✗
Timestamps✗✓
Web compatibility✓✗

When to use GeoJSON

For web maps, storing polygons/lines/points, APIs.

When to use GPX

For GPS devices, Strava/Komoot, hiking tracks.

What is GeoJSON?

Example OpenStreetMap map exported to GeoJSON
GeoJSON: an OpenStreetMap map exported by osm2cdr.

GeoJSON was designed in 2008 by a working group of developers and standardised by the IETF as RFC 7946 in 2016. It encodes geographic features in JavaScript Object Notation, which made it the default exchange format of web mapping and of most geospatial APIs.

A typical file is a FeatureCollection: an array of features, each with a geometry (Point, LineString, Polygon or their Multi variants) and a free-form properties object. Coordinates are decimal longitude and latitude. There are no styles, no spatial index and no fixed schema — every feature may carry different properties.

Software that opens GeoJSON

Leaflet, MapLibre GL, OpenLayers and D3.js load GeoJSON directly; QGIS, ArcGIS Pro, GDAL/ogr2ogr, GeoPandas and PostGIS import it, and GitHub previews GeoJSON files on a map.

Where GeoJSON is strong

It is readable by humans, parsed by every programming language and needs no companion files. Properties can hold any number of attributes with long names and Unicode values, which makes the format ideal for web APIs and small to medium datasets.

Limitations of GeoJSON

Text encoding makes files big and slow once they reach millions of features, there is no spatial index, and the single fixed coordinate system means projected data must be reprojected. Mixed geometry types in one file confuse desktop tools that expect one type per layer.

What osm2cdr puts into a GeoJSON file

osm2cdr writes one FeatureCollection holding every layer of the selected area. Each feature keeps its OpenStreetMap name, type and tags, plus a _layer property naming its source layer — roads, buildings, water, greenery or points of interest — so a single filter splits the data apart again.

What is GPX?

Example OpenStreetMap map exported to GPX
GPX: an OpenStreetMap map exported by osm2cdr.

GPX (GPS Exchange Format) was released by TopoGrafix in 2002, and the current version, GPX 1.1, dates from 2004. It is an open, lightweight XML schema for moving location data between GPS devices and software.

A GPX file holds three kinds of data: waypoints (single named points), routes (ordered lists of points to follow) and tracks (recorded paths made of segments of track points). Each point has latitude and longitude plus optional elevation, time, name and description; extensions add things such as heart rate.

Software that opens GPX

Garmin BaseCamp and Garmin devices, Wahoo and Hammerhead bike computers, Strava, Komoot, OsmAnd, Locus Map, GPXSee and QGIS read GPX.

Where GPX is strong

It is the common language of navigation devices and sports apps, so a file prepared on a computer reaches a watch or a handlebar unit without conversion. Time stamps make it the natural format for recorded activities.

Limitations of GPX

GPX has no polygons, no styling and only minimal attributes, so an area becomes just its outline. A track is geometry, not turn-by-turn guidance, and files with very many points slow down small devices.

What osm2cdr puts into a GPX file

osm2cdr turns points of interest into waypoints that show up as markers on the device screen, and linear features into lines you can walk or ride along. Areas arrive as outlines only, point elevations are not filled in, and turn prompts are left to the navigator's own routing data.

Key differences explained

At the most basic level, GeoJSON is a JSON-based open format for geographic features, while GPX is an XML format for GPS waypoints, routes and tracks. On disk, GeoJSON is plain UTF-8 JSON text; GPX is plain XML text.

Here is what the comparison table above means in practice, point by point:

Example OpenStreetMap map exported to GeoJSON-Seq
A related export: the same kind of map in GeoJSON-Seq, a format often used next to GeoJSON.

In short: choose GeoJSON when the data feeds a web map, an API or a script. Choose GPX when the features have to end up on a GPS navigator, a bike computer or a sports app.

GeoJSON or GPX: which one fits your job?

You want hiking paths and viewpoints in OsmAnd or on a Garmin watch. GPX is the format these apps and devices import without any conversion.

You are analysing the same paths by surface type, access rules or trail difficulty. GeoJSON keeps all OpenStreetMap properties, which GPX has no room for.

You are showing trails on a website and want to colour them by type. GeoJSON draws them in Leaflet with styling by tag, while GPX would need a plugin and offers only names.

Pitfalls when switching between GeoJSON and GPX

GPX supports only points and lines, so converting GeoJSON polygons yields outlines or nothing, and properties shrink to a name and a description. Converting GPX to GeoJSON keeps the geometry, but time and elevation end up as properties or third coordinates depending on the tool. Keep in mind that osm2cdr's GPX is a set of waypoints and lines for the device, not a planned route with turn instructions.

If you plan a trip and analyse it afterwards, take both: load the GPX onto the device for navigation and keep the GeoJSON on your computer, where the full OSM tags let you check surfaces, access restrictions and points of interest along the way.

Which to pick on osm2cdr

On osm2cdr, pick GPX for navigation devices, bike computers and outdoor apps. Pick GeoJSON for analysis, web maps and anything that needs the full set of OSM tags.

How to get GeoJSON or GPX from OpenStreetMap

osm2cdr builds GeoJSON and GPX directly from OpenStreetMap data — there is no need to download raw OSM extracts or install conversion tools. The steps:

  1. Open the osm2cdr map for GeoJSON and find your place by name, or draw a rectangle around the area.
  2. Choose GeoJSON or GPX in the format list and set the options offered for it, such as map layers, style or sheet size.
  3. Start the export and download the result: GeoJSON arrives as a .geojson file; GPX arrives as a .gpx file.
  4. Need GPX as well as GeoJSON? Run a second export of the same area. Both start from the same OpenStreetMap data, but each keeps only what its format can hold, as described in the sections on GeoJSON and GPX above.

Converter pages related to GeoJSON and GPX explain each route in more detail:

Frequently asked questions

What is the main difference between GeoJSON and GPX?

GeoJSON is a JSON-based open format for geographic features, whereas GPX is an XML format for GPS waypoints, routes and tracks. In the comparison table, GeoJSON is ahead on data attributes and web compatibility; GPX is ahead on GPS devices and timestamps.

Which is better for data attributes, GeoJSON or GPX?

GeoJSON. It is readable by humans, parsed by every programming language and needs no companion files.

When does GPX beat GeoJSON?

When GPS devices and timestamps matter most. It is the common language of navigation devices and sports apps, so a file prepared on a computer reaches a watch or a handlebar unit without conversion.

Can I convert GeoJSON to GPX?

There is no dedicated GeoJSON-to-GPX converter page on osm2cdr. Both formats are exported directly from OpenStreetMap data: select an area once and run the export for each format you need.

Which programs open GeoJSON and GPX files?

GeoJSON files open in Leaflet, MapLibre GL, OpenLayers, QGIS, GDAL and GeoPandas. GPX files open in Garmin BaseCamp, Strava, Komoot, OsmAnd, GPXSee and QGIS.

Do GeoJSON and GPX keep real-world coordinates?

GeoJSON is fixed by RFC 7946 to WGS 84 longitude and latitude, and osm2cdr follows the rule, so every feature is ready for web maps. GPX stores WGS 84 latitude and longitude, with optional elevation and time for every point.

Export to GeoJSON Export to GPX