How to Merge GPX Files: Free Tool + Python + GPSBabel Guide (2026)

GPX files pile up fast. A multi-day hike becomes one file per day, a GPS watch can split a single run into multiple recordings, and waypoint collections often end up scattered across exports.
Merging GPX sounds simple, but the “right” approach depends on what you’re combining: tracks, waypoints, routes, or all of them together. Some tools also handle timestamps, segments, and metadata better than others.
This guide covers several practical methods: a quick browser-based merge, Python for automation, GPSBabel for command-line workflows, and a few common app-based options.
What Is a GPX File?
GPX: GPS Exchange Format.
XML-based file format. Universal standard for sharing GPS data between devices, mapping software, and fitness applications.
TopoGrafix created it. Pretty much every GPS device and app supports it.
GPX file contains three data types:
Tracks represent ordered sequences of GPS points recording where you've been.
Each track contains one or more track segments with individual trackpoints. Include latitude, longitude, elevation, and timestamp data.
Think of tracks as breadcrumb trail device records as you move.
Waypoints represent individual points of interest.
Name, description, and coordinates. Like pins on map, marking specific saved locations.
Routes represent planned paths consisting of ordered route points.
Unlike tracks (record where actually went), routes represent where intend to go.
Here's what a typical GPX file looks like under the hood:
<?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 the Free Online GPX Merger (No Code Required)
This is the simplest approach when you just want to combine GPX files quickly. Everything runs locally in the browser for privacy.
Try it here: merge-json-files.com/gpx-merger
How it works:
- Open the GPX merger page
- Drag and drop GPX files (or browse to select them)
- Choose a merge strategy:
- All elements: merge tracks, waypoints, and routes
- Tracks only: combine only track data
- Waypoints only: merge only saved locations
- Routes only: combine only routes
- Optionally enable "Consolidate into single track" to create one continuous track
- Set a custom name (optional)
- Click "Merge GPX Files"
- Review statistics (tracks, waypoints, routes, points)
- Download the merged GPX
The merge runs locally using the browser, and it handles GPX 1.0 and 1.1 from common sources (Garmin, Suunto, Coros, Apple Watch, Strava, Komoot, AllTrails, and more). This option is a good fit for small to medium batches when the main goal is a quick, clean combined file.
Method 2: Merge GPX Files Using Python
When you need automation or custom merge logic, Python with the gpxpy library is hard to beat.
Install gpxpy:
pip install gpxpy
Basic GPX Merge Script:
import 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
import 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:
def 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:
gpsbabel -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):
gpsbabel -t -i gpx -f track1.gpx -i gpx -f track2.gpx \
-o gpx -F merged_tracks.gpx
Merge Only Waypoints:
gpsbabel -w -i gpx -f file1.gpx -i gpx -f file2.gpx \
-o gpx -F merged_waypoints.gpx
Remove Duplicate Waypoints:
gpsbabel -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):
# 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 (
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 can easily reach 500,000+ points across multiple files. The browser-based merge option handles large files well, but for very large batches, Python or GPSBabel is typically more reliable.
Best Practices for Merging GPX Files
- Name files sequentially. Date-based names like 2025-06-01_day1.gpx and 2025-06-02_day2.gpx sort naturally in the right order.
- Back up originals so it’s easy to re-merge with different settings.
- Choose the right strategy. Keep tracks separate for multi-day hikes, consolidate when an activity was accidentally split.
- Verify on a map. Import into Google Earth, Strava, Komoot, or another mapping tool to confirm everything looks right.
- Clean up obvious spikes or bad points before merging.
- Consider file size. Some devices struggle with huge tracks, so simplifying point density can help.
- Preserve metadata. Add a clear name and description so the merged file is still understandable later.
- Test with the target device before relying on it for navigation.
Real-World Merge Scenarios
Multi-Day Thru-Hike
For a long trek where each day is recorded separately, export the daily GPX files, merge them using the "All elements" strategy (to keep waypoints like rest stops), and avoid consolidating into a single track if separate days are easier to visualize. Upload the merged result to Strava, Komoot, or Google Earth to view the full route.
Accidentally Split Activity
If a watch battery dies mid-run and you end up with two recordings, merge the files and enable "Consolidate into single track" to create one continuous activity.
Waypoint Collection
When the goal is a master waypoint file, merge using "Waypoints only" and load the consolidated output onto the GPS device.
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?
Yes. GPX is standardized, so files from Garmin, Suunto, Coros, Apple Watch, and phones follow the same core schema. The merge preserves standard GPX elements regardless of which device created the file.
Will merging GPX files affect my distance calculations?
No. Trackpoints keep their original coordinates and timestamps. The main exception is consolidation: if separate tracks are stitched into one, the “gap” between the end of one track and the start of the next can be counted as distance by some apps.
Can I merge hundreds of GPX files at once?
It depends on browser memory for a browser-based merge. For very large batches (1000+ files), Python with gpxpy or GPSBabel is usually more reliable.
How do I merge GPX files on my phone?
Open merge-json-files.com/gpx-merger in a mobile browser. The page 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. The merge preserves core GPX data (coordinates, elevation, time). If extension preservation is required, use Python with gpxpy or GPSBabel.
Final Thoughts
A good GPX merge comes down to choosing the right strategy (keep tracks separate vs consolidate) and always validating the result on a map before relying on it.
Related Guides: Learn more about working with data files in how to merge JSON files and how to split JSON files.
Read More
All Articles
How to Create JSON File in Java: org.json, Gson & Jackson (2026)
Create JSON files in Java using org.json, Gson, or Jackson libraries. Complete guide with code examples for JSON creation, file writing, nested objects, and best practices for Java developers.

How to Add Image in JSON: URL, Base64 & File Path Methods (2026)
Add images to JSON using URLs, base64 encoding, or file paths. Complete guide with code examples, size optimization tips, and best practices for each method in web and mobile apps.

How to Merge VCF Files: Free Tool + Duplicate Removal Guide (2026)
Merge multiple VCF (vCard) contact files with free online tool, Python, or command line. Includes duplicate removal, contact sorting, and migration between iPhone, Android, Google, and Outlook.