How to Merge GPX Files: The Complete Step-by-Step Guide
Imad Uddin
Full Stack Developer

If you track your outdoor activities with a GPS device, you've probably run into this: you hiked a five-day trail and now you have five separate GPX files instead of one beautiful complete route. Or maybe your watch died mid-run, and now your Saturday long run is split across two files. Maybe you've collected waypoints over a dozen weekend trips and want them all in one master file.
Whatever the situation, merging GPX files is one of those tasks that sounds like it should be simple but can get tricky depending on the tools you use. I've dealt with this enough times with my own Garmin data that I figured it was worth writing up every method I know. We'll cover a free online tool, Python scripts, GPSBabel commands, and even mapping applications. By the end, you should be able to combine any set of GPX files regardless of how they were recorded or which device created them.
What Is a GPX File?
GPX stands for GPS Exchange Format. It's an XML-based file format that's become the universal standard for sharing GPS data between devices, mapping software, and fitness applications. TopoGrafix created it, and pretty much every GPS device and app supports it.
A GPX file can contain three types of data:
Tracks are ordered sequences of GPS points that record where you've been. Each track contains one or more track segments with individual trackpoints that include latitude, longitude, elevation, and timestamp data. Think of tracks as the breadcrumb trail your device records as you move.
Waypoints are individual points of interest with a name, description, and coordinates. These are like pins on a map, marking specific locations you've saved.
Routes are planned paths consisting of ordered route points. Unlike tracks (which record where you actually went), routes represent where you intend to go.
Here's what a typical GPX file looks like under the hood:
XML<?xml version="1.0" encoding="UTF-8"?> <gpx version="1.1" creator="Garmin Connect" xmlns="http://www.topografix.com/GPX/1/1"> <metadata> <name>Morning Run</name> <time>2025-06-10T07:30:00Z</time> </metadata> <trk> <name>Morning Run</name> <trkseg> <trkpt lat="40.7128" lon="-74.0060"> <ele>10.5</ele> <time>2025-06-10T07:30:00Z</time> </trkpt> <trkpt lat="40.7130" lon="-74.0058"> <ele>11.2</ele> <time>2025-06-10T07:30:05Z</time> </trkpt> </trkseg> </trk> <wpt lat="40.7580" lon="-73.9855"> <name>Times Square</name> <desc>Famous intersection in NYC</desc> </wpt> </gpx>
Why Merge GPX Files?
There's no shortage of reasons to combine multiple GPX files into one:
Multi-day hikes where each day is recorded separately and you want the complete thru-hike in a single file. Cycling tours where you've recorded each stage individually. Split activities from a GPS device that lost signal or ran out of battery mid-workout. Waypoint collections from multiple scouting trips that you want consolidated into one master list. Separately planned route segments that need to become a single navigable route. Sailing logs, road trip recordings, mountaineering expeditions with approach and descent tracks, or even geocaching waypoint lists from different regions.
If you work with GPS data regularly, you'll need to merge files at some point. Let's get into how.
Method 1: Use Our Free Online GPX Merger Tool (No Code Required)
The simplest approach by far. No software to install, no code to write, and your GPS data stays private because everything runs in your browser.
Try it here: merge-json-files.com/gpx-merger
Here's how it works:
- Go to our GPX Merger Tool
- Drag and drop your GPX files or click to browse
- Choose your merge strategy:
- All elements merges tracks, waypoints, and routes together
- Tracks only extracts and combines just the track data
- Waypoints only merges only your saved locations
- Routes only combines route data exclusively
- Optionally enable "Consolidate into single track" to merge all tracks into one continuous track
- Give your merged track a custom name
- Hit "Merge GPX Files"
- Check the statistics (total tracks, waypoints, routes, and data points)
- Download the merged GPX file
Everything processes locally using the browser's DOMParser API, so your data never leaves your machine. The tool correctly handles both GPX 1.0 and 1.1 formats from any device, whether that's Garmin, Suunto, Coros, Apple Watch, Strava, Komoot, AllTrails, or anything else. You can drag and drop to reorder files, and there's no limit on how many files you can merge beyond your browser's memory.
This is the option I'd suggest for hikers combining multi-day trek recordings, cyclists merging tour data, or anyone who just wants to get it done quickly.
Method 2: Merge GPX Files Using Python
When you need automation or custom merge logic, Python with the
gpxpyInstall gpxpy:
Bashpip install gpxpy
Basic GPX Merge Script:
Pythonimport gpxpy import glob def merge_gpx_files(input_files, output_file): """Merge multiple GPX files into one.""" merged_gpx = gpxpy.gpx.GPX() for filepath in input_files: with open(filepath, 'r') as f: gpx = gpxpy.parse(f) # Copy tracks for track in gpx.tracks: merged_gpx.tracks.append(track) # Copy waypoints for waypoint in gpx.waypoints: merged_gpx.waypoints.append(waypoint) # Copy routes for route in gpx.routes: merged_gpx.routes.append(route) # Write merged file with open(output_file, 'w') as f: f.write(merged_gpx.to_xml()) total_points = sum( len(seg.points) for track in merged_gpx.tracks for seg in track.segments ) print(f"Merged {len(input_files)} files") print(f"Tracks: {len(merged_gpx.tracks)}") print(f"Waypoints: {len(merged_gpx.waypoints)}") print(f"Total points: {total_points}") # Usage files = sorted(glob.glob("./tracks/*.gpx")) merge_gpx_files(files, "merged_trek.gpx")
Advanced: Merge All Tracks into One Continuous Track
Pythonimport gpxpy import glob def merge_into_single_track(input_files, output_file, track_name="Merged Track"): """Merge all GPX files into a single continuous track.""" merged_gpx = gpxpy.gpx.GPX() merged_track = gpxpy.gpx.GPXTrack(name=track_name) merged_segment = gpxpy.gpx.GPXTrackSegment() for filepath in sorted(input_files): with open(filepath, 'r') as f: gpx = gpxpy.parse(f) for track in gpx.tracks: for segment in track.segments: for point in segment.points: merged_segment.points.append(point) # Also copy waypoints for waypoint in gpx.waypoints: merged_gpx.waypoints.append(waypoint) merged_track.segments.append(merged_segment) merged_gpx.tracks.append(merged_track) # Sort points by time if available if merged_segment.points and merged_segment.points[0].time: merged_segment.points.sort(key=lambda p: p.time or p.time) with open(output_file, 'w') as f: f.write(merged_gpx.to_xml()) print(f"Merged into single track: {len(merged_segment.points)} points") # Usage files = glob.glob("./daily_tracks/*.gpx") merge_into_single_track(files, "complete_trek.gpx", "Pacific Crest Trail 2025")
Remove Duplicate Waypoints:
Pythondef remove_duplicate_waypoints(gpx_data): """Remove waypoints with identical coordinates.""" seen = set() unique_waypoints = [] for wpt in gpx_data.waypoints: key = (round(wpt.latitude, 6), round(wpt.longitude, 6)) if key not in seen: seen.add(key) unique_waypoints.append(wpt) gpx_data.waypoints = unique_waypoints return gpx_data
Python gives you full control over merge logic with the ability to filter, sort, deduplicate, and even calculate statistics like distance and elevation gain. You can easily handle hundreds of files in a single run. The tradeoff is that it requires Python and gpxpy to be installed, and there's more setup involved compared to the online tool.
Method 3: Merge GPX Files with GPSBabel (Command Line)
GPSBabel is a free command-line tool built specifically for converting and manipulating GPS data files. It supports over 100 GPS file formats, which makes it incredibly versatile.
Install GPSBabel:
- Windows: Download from gpsbabel.org
- macOS:
brew install gpsbabel - Linux:
sudo apt install gpsbabel
Basic Merge:
Bashgpsbabel -i gpx -f track1.gpx -i gpx -f track2.gpx -i gpx -f track3.gpx \ -o gpx -F merged.gpx
Merge Only Tracks (Ignore Waypoints):
Bashgpsbabel -t -i gpx -f track1.gpx -i gpx -f track2.gpx \ -o gpx -F merged_tracks.gpx
Merge Only Waypoints:
Bashgpsbabel -w -i gpx -f file1.gpx -i gpx -f file2.gpx \ -o gpx -F merged_waypoints.gpx
Remove Duplicate Waypoints:
Bashgpsbabel -w -i gpx -f file1.gpx -i gpx -f file2.gpx \ -x duplicate,location -o gpx -F merged_unique.gpx
Merge All GPX Files in a Directory (Bash):
Bash# Build the command dynamically CMD="gpsbabel" for f in ./tracks/*.gpx; do CMD="$CMD -i gpx -f $f" done CMD="$CMD -o gpx -F merged_all.gpx" eval $CMD
GPSBabel is purpose-built for GPS data, so it handles edge cases that generic tools miss. It has built-in filters for duplicates, track simplification, and more. Processing is fast even with large files. The syntax can get verbose when you're working with many input files, and some advanced GPX extensions may be stripped during the merge.
Method 4: Merge GPX Files in Mapping Applications
Several mapping and GPS applications offer built-in merge capabilities:
Garmin BaseCamp: Import all your GPX files, select all the tracks and waypoints you want to merge, right-click and choose "Combine Selected Tracks," then export the combined data as a new GPX file.
QGIS (Free GIS Software): Drag your GPX files into QGIS, use the "Merge Vector Layers" tool from the Processing Toolbox, then export the merged layer as GPX.
Online Alternatives: GPX Studio (gpx.studio) offers a visual GPX editor with merge capabilities. AllTrails lets you import and combine routes if you have an account.
Comparison of GPX Merge Methods
| Method | Best For | Skill Level | Batch Support | Track Consolidation | Waypoint Dedup |
|---|---|---|---|---|---|
| Online Tool | Quick merges | Beginner | Yes | Yes | No |
| Python | Automation | Intermediate | Yes | Yes | Yes |
| GPSBabel | CLI workflows | Advanced | Yes | No | Yes |
| Garmin BaseCamp | Garmin users | Beginner | No | Yes | No |
| QGIS | GIS analysis | Advanced | Yes | Yes | Yes |
Common Challenges When Merging GPX Files
Files from Different GPS Devices
Different devices record different data fields. A Garmin watch might include heart rate and cadence extensions, while a phone GPS app records only coordinates. When merging, the core data (latitude, longitude, elevation, and time) always carries over fine. Device-specific extensions like heart rate or power data only show up in segments from the device that recorded them. Some devices record coordinates to 6 decimal places (about 11cm accuracy), while others use fewer.
Timezone and Time Gap Issues
When you merge tracks recorded on different days, keep in mind that timestamps in GPX files are always stored in UTC (Coordinated Universal Time). Time gaps between files are normal and expected. If you consolidate into a single track, the gap shows up as a straight line on the map between the last point of one file and the first point of the next. If the time or location gaps are large, you're usually better off keeping tracks separate rather than consolidating.
Track Segment Breaks
Within a single track, segment breaks (
<trkseg>Overlapping Tracks
If two GPX files cover the same route (like heading out and coming back on the same path), both tracks are preserved. The merger doesn't remove duplicates in track data. For waypoints, though, you can use deduplication to remove identical points.
Large File Sizes
GPX files with high-frequency recording (1-second intervals) can get big. A full day of 1-second recording produces roughly 86,400 points per track. A week-long trek could have 500,000+ points across multiple files. Our online tool handles large files well, but for very large merges, Python or GPSBabel will be more reliable.
Best Practices for Merging GPX Files
Name your files sequentially. Use date-based names like
2025-06-01_day1.gpx2025-06-02_day2.gpxBack up originals. Always keep a copy of the original files before merging. You might want to re-merge with different settings later.
Choose the right merge strategy. Keep tracks separate for multi-day hikes so each day is visible. Consolidate for activities that were accidentally split.
Verify on a map. After merging, import the result into Google Earth, Strava, Komoot, or another mapping tool to make sure everything looks correct.
Clean up before merging. Remove erroneous waypoints or track spikes from individual files first. Garbage in, garbage out.
Consider file size. If the merged file is very large, some devices or apps may struggle to load it. You might need to simplify tracks by reducing point density before merging.
Preserve metadata. Add a descriptive name and description to the merged file so you remember what it contains six months from now.
Test with your target device. Before a trip, verify the merged file actually loads correctly on your GPS device. There's nothing worse than discovering a compatibility issue when you're already on the trail.
Real-World Merge Scenarios
Multi-Day Thru-Hike
Say you're hiking the Camino de Santiago over 35 days, recording each day separately on your GPS watch. Export all 35 daily GPX files from your device, upload them to our GPX Merger Tool, keep the merge strategy as "All elements" to preserve waypoints like rest stops and hostels, and don't consolidate into a single track since keeping each day separate makes for clearer visualization. Download the result and upload to Strava, Komoot, or Google Earth to view the complete route.
Accidentally Split Activity
Your GPS watch lost battery mid-run, so now you have two files for a single workout. Upload both GPX files, enable "Consolidate into single track," name the merged track "Saturday Long Run," and the tool joins the two segments into one continuous track. Upload to Strava and you'll get the correct total distance and pace.
Waypoint Collection
You've scouted camping spots across multiple weekend trips and want a master waypoint file. Upload all GPX files from your scouting trips, set the merge strategy to "Waypoints only," download the consolidated file, and load it onto your GPS device for future reference.
Working with GPX Files from Popular Platforms
Downloading GPX from Strava: Open the activity on Strava, click the three dots menu, and select "Export GPX."
Downloading GPX from Garmin Connect: Open the activity in Garmin Connect, click the gear icon, and select "Export to GPX."
Downloading GPX from Komoot: Open the tour in Komoot, click "More," then "Download GPX."
Downloading GPX from AllTrails: Open the trail or recording and click "GPX Download" (may require a subscription).
Frequently Asked Questions
Can I merge GPX files from different GPS devices?
Absolutely. GPX is a standardized format. Files from Garmin, Suunto, Coros, Apple Watch, and phones all follow the same XML schema. Our tool parses the standard elements correctly regardless of which device created the file.
Will merging GPX files affect my distance calculations?
No. Each trackpoint keeps its original coordinates and timestamps. Any app calculating distance from the merged file will get the same results as processing the individual files separately. The one exception: if you consolidate separate tracks into one, the "gap" between the end of one track and the start of the next gets included in total distance.
Can I merge hundreds of GPX files at once?
With our online tool, you can merge many files limited only by your browser's memory. For very large batches (1000+ files), Python with gpxpy or GPSBabel will be more reliable. For typical use cases of 2 to 100 files, the online tool works great.
How do I merge GPX files on my phone?
Visit merge-json-files.com/gpx-merger in your mobile browser. The tool is fully responsive and works on both iOS and Android.
What happens to heart rate and cadence data?
GPX extensions like heart rate, cadence, power, and temperature are device-specific XML extensions. Our tool preserves the core GPX data (coordinates, elevation, time). For preserving extension data, use Python with gpxpy or GPSBabel.
Related Tools and Resources
- GPX File Merger Tool for merging GPX files online for free
- WAV File Merger for combining audio files
- VCF Contact Merger for merging vCard contact files
- JSON File Merger for combining JSON data files
- CSV File Merger for merging CSV datasets
Final Thoughts
Merging GPX files is something you'll need to do sooner or later if you regularly work with GPS data. Whether it's combining a month-long cycling tour into a single file, consolidating your waypoint collection, or fixing an accidentally split activity, having the right tool makes all the difference.
For quick, private merges, our online GPX merger tool is free, browser-based, and your data never leaves your device. For automated processing of large batches, Python with the gpxpy library gives you full control. For command-line efficiency, GPSBabel handles pretty much any GPS format conversion and merge you can throw at it. For visual editing, Garmin BaseCamp, QGIS, or GPX Studio let you see exactly what you're doing.
The key to a solid GPX merge is choosing the right strategy (keep tracks separate vs. consolidate) and always verifying the result on a map before relying on it for navigation.
Try our GPX File Merger Tool for free, instant, and completely private merging.
Related Guides: Learn more about working with data files in our guides on how to merge JSON files and how to split JSON files.
Read More
All Articles
How to Create a JSON File in Java: Beginner to Advanced Guide
Learn how to create a JSON file in Java step by step using popular libraries like org.json and Gson. This detailed guide covers JSON creation, file writing, real-world examples, and best practices for beginners and developers alike.

How to Add an Image in JSON: A Comprehensive Guide
Learn how to add an image to a JSON object using URLs, file paths, or base64 encoding. This guide provides examples and best practices for each method.

How to Format JSON in Notepad++: Simple Step-by-Step Guide
Learn how to format JSON in Notepad++ using easy, beginner-friendly steps. This guide covers plugin installation, formatting shortcuts, troubleshooting tips, and real-life examples for developers and non-tech users alike.