GPS to GPX
A simple tool that uses GPS waypoint data to generate GPX.
Let's say you use a service like Nike+ for tracking your runs. Being a curious person, you're interested in trying out some other services to see what they're like, or maybe you've decided to start doing some cycling and now want to track all your different activities in one place, like Strava, and you want to take your data with you. A common way of doing this is to download your data as a GPX file and import it into other services. Nike+ (inexplicably) doesn't let you export data from your runs, but it does have an API that lets you grab JSON data for each activity. So, you're kind of stuck; you have some JSON data but you want GPX files. That's where this library comes in handy!
You might have JSON data that looks like this:
Let's assume the JSON data above has been saved to a
data variable and you're using ES2015 (if you're using another environment, you can find the appropriate steps in the installation instructions). Now you can
import the default top-level
createGpx function and call it like so :
;const gpx =;console;
For all your hard work, you'll be rewarded with GPX output in your console that looks like this:
See how easy that was? Just send in your GPS waypoints, and you'll get back nicely formatted GPX created from your data! You can now do whatever you want with this, like save it to a file.
If you're using npm as your package manager, you can install the most recent, stable version like so:
npm install --save gps-to-gpx
In an ES2015 environment, you can import the library like this:
In a CommonJS environment, you can import the library like this:
const createGpx = default;
If you're not using modules via something like webpack, Browserify, or Node.js, then the UMD build might interest you. The
gps-to-gpx library comes with a
dist folder containing development and (minified) production UMD builds that can be used without a module bundler. In a UMD environment, GPS to GPX will be available as the
The source code is written in ES2015 but is compiled to ES5 ahead of time in both CommonJS (
lib folder) and UMD (
dist folder) builds.
This is a minimal library, so it only exports one function with a few options for GPX file customization:
waypoints(array): Required. An array of GPS waypoint data. Each point should be an object containing, at the very least, keys representing a coordinate's latitude and longitude values. These keys are assumed to be "latitude" and "longitude" by default, but can be customized (see
options(object): Optional. An object literal of options that customize/override the default library settings. If any options are omitted, the settings will use the default values listed below:
activityName: "Everyday I'm hustlin'"
creator: 'Patrick Hooper'
(string): A GPX (a form of XML) string composed of the given waypoints and options.
If you're not sure where to start with the GPS to GPX library, maybe the example(s) below can help:
Contributions from the community are welcome and encouraged! If you have any ideas, feature requests, bugs, etc., please use the contributing guidelines to determine your next move. Also note that this project follows a code of conduct. Thank you!
GPS to GPX is released under the MIT License.