Skip to main content

fitstitch

Stitch FIT activities that were accidentally split (stopped and saved halfway) back into one, offline and without losing data. The result is the activity you would have had if you had pressed pause instead of saving.

It works with FIT files from any device (Garmin, Suunto, Wahoo, Coros…), and the stitched file uploads to Garmin Connect, Strava and other sports apps.

$ fit-stitch part1.zip part2.zip -o run.fit
                               Part 1               Part 2             Stitched
Start             2026-10-25 12:39:12  2026-10-25 13:43:54  2026-10-25 12:39:12
Distance                      7.27 km              4.19 km             11.46 km
Timer time                    0:53:51              0:26:08              1:19:59
Elapsed time                  1:04:03              0:27:12              1:31:54
...
Pause between part 1 and 2: 0:00:39

  [ok] file structure and CRC are valid
  [ok] Garmin FIT SDK decodes the file without errors
  [ok] all 16929 data messages preserved
  ...

Use it in your browser

https://jmallach.github.io/fitstitch/ runs the same code in your browser, with nothing to install, on phones too. Your files are not uploaded: the page runs fitstitch locally with Pyodide (Python compiled to WebAssembly). It is available in 38 languages, from Arabic and Hindi to Catalan and Japanese; corrections are welcome (see CONTRIBUTING.md).

Install

pipx install git+https://github.com/jmallach/fitstitch

or, from a checkout, pip install ..

Requires Python 3.9+ and the official garmin-fit-sdk package. That package is used for field names and units, and to check the output independently.

Usage

fit-stitch PART1 PART2 [PART3...] [-o OUTPUT] [-n] [-f] [--overwrite]
  • Inputs are .fit files, or .zip files holding one (such as Garmin Connect's Export Original). You can give them in any order; they are sorted by start time.
  • -n/--dry-run shows the result and the checks without writing anything.
  • -f/--force stitches parts even if the sport or the recording device differ.
  • If the output fails any check, the tool writes nothing and exits with status 2.

Replacing the original activities

  1. Export the original FIT file of each part from your sports app. On the Garmin Connect website: activity → ⚙ → Export Original; on the Strava website: activity → ⋯ → Export Original. Their phone apps can't export files; in a phone's browser, ask for the desktop site if it keeps opening the app.
  2. Run fit-stitch, or use the web page.
  3. Delete the original parts wherever they were uploaded. Garmin Connect, Strava and most other apps reject an activity with the same start time as an existing one as a duplicate. Kudos, comments, photos, titles and gear on the parts are lost.
  4. Upload the stitched file to Garmin Connect (Import Data), Strava (strava.com/upload/select) or any other app that accepts FIT files. If your apps sync with each other, uploading it to one may be enough.

What it does

The FIT file is read and written byte by byte. Every message and field is copied as it was, including undocumented Garmin messages and developer (Connect IQ) fields. The tool only changes fields whose meaning it knows.

  • Data streams: records, GPS metadata, events, sensor and device info, HRV, battery and ClimbPro data are kept from all parts. Accumulating record fields (distance, accumulated power, cycles) continue from the end of the previous part instead of restarting at zero.
  • The gap between parts becomes a pause. The timer stop/start events that mark it are added if the files lack them.
  • Session: totals are added up; averages are weighted by timer time (speed is total distance / timer time). Maximums, minimums, the bounding box and normalized power (4th-power weighted mean) are combined. Elapsed time runs from the first start to the last end.
  • Laps are kept as recorded and renumbered. The last lap before a gap absorbs the pause, as a real pause inside a lap would: its elapsed time grows and its timer time stays the same. This keeps laps contiguous and their elapsed times adding up to the session's, as Garmin's validator requires.
  • Splits (run/walk/stand detection, intervals) are renumbered. The whole-activity interval split and the per-type split summaries are merged.
  • Time in zone (HR/power/speed/cadence) is added up for the session and re-linked to the renumbered laps and splits.
  • Best efforts (fastest 1 km, 1 mile, 5 km… as recorded by the watch): the fastest of the parts is kept.
  • Setup messages (user profile, device settings, sport, zones, course): the first part's copy is kept.
  • Layout: the first part's message order is followed. Some devices (such as newer Garmin watches) write summaries before the data; others write them after.

Limitations

  • Values calculated on the watch (Training Effect, training load, recovery time, VO2max update) come from the watch maker's proprietary algorithms and cannot be recalculated. The tool keeps the higher Training Effect of the parts and adds up training load, which leaves your weekly load unchanged.
  • Auto laps restart at the beginning of each part, so the lap before the gap is a partial one, as if you had pressed the lap button.
  • Data during the gap was never recorded and cannot be recovered.
  • Multisport activities and pool swimming (length messages) are refused.
  • GPX/TCX input is not supported: those formats drop most of the data.

Development

python -m venv .venv && .venv/bin/pip install -e '.[test]'
.venv/bin/python tools/fetch_corpus.py      # public FIT files
.venv/bin/python tools/fetch_fitcsvtool.py  # optional: Garmin's validator (needs Java)
.venv/bin/pytest

The tests work at three levels:

  • tests/test_stitch.py builds synthetic FIT files. It covers both file layouts, three or more parts, compressed timestamps, developer fields, missing timer events, time in zone and the error cases.
  • tests/test_corpus.py runs on about 45 public FIT files (from Garmin, Wahoo, Coros, Zwift and others, plus deliberately broken files) taken from the test suites of fitdecode, python-fitparse and the official Garmin SDKs. Every file must either round-trip byte for byte or be refused with a clear error. Every activity is cut into halves and into thirds with fit-split and stitched back, and the result must reproduce the original data stream exactly.
  • Real split activities are stitched and verified too: anonymized ones in tests/data/<case>/ (so far a Suunto Ambit3 run whose second half lost the heart-rate strap), and your own in samples/<case>/, which is not distributed. See CONTRIBUTING.md.

Every stitched file in the tests is also checked by independent decoders:

  • fitdecode must decode every message and field value exactly as fitstitch's own reader does.
  • Garmin's FitCSVTool runs its activity file validation (-t), the checks Garmin applies to activity files. Stitching must not introduce a failure the input files did not already have. This check runs when tools/.cache/FitCSVTool.jar (or $FITCSVTOOL_JAR) and Java are available, as they are in CI. FitCSVTool is published by Garmin under its FIT Protocol License and is downloaded, never redistributed.

The tool's own output checks include the same summary rules as Garmin's validator, with the same tolerances: laps must be contiguous, and lap elapsed and timer times must add up to the session's.

The web frontend lives in web/. tools/build_web.py bundles it with wheels of fitstitch and garmin-fit-sdk into _site/ (serve it with python -m http.server -d _site), and GitHub Pages publishes it on every push to main. tests/test_web.py drives the page in headless Chromium and checks that it produces the same file as the Python API; it needs pip install playwright && playwright install chromium and is skipped otherwise.

fit-split FILE 0.5 cuts an activity into parts as if it had been stopped and restarted. It is meant for testing.

License

MIT. See LICENSE.

Metadata

Release files for fitstitch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fitstitch 0.1.0
File Size Uploaded Provenance Actions
fitstitch-0.1.0.tar.gz 27.3 kB With provenance Details for fitstitch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fitstitch 0.1.0
File Interpreter ABI Platform Actions
fitstitch-0.1.0-py3-none-any.whl Python 3 none any Details for fitstitch-0.1.0-py3-none-any.whl

Total release size: 53.2 kB

Release files / fitstitch-0.1.0.tar.gz

Download URL fitstitch-0.1.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
758156ec71a39df5edf7ff06ebda73b6b0543beb0b50b5456920ef2bf0ba5bb1
BLAKE2b-256 checksum
How to use checksums
78aad31ea921d435bcc32f1134dac922074ae310d7a11465573e55c4590ae2f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fitstitch-0.1.0-py3-none-any.whl

Download URL fitstitch-0.1.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cee32b27bdd44a3fe61ffeeaea6b2f9926d98e453857048ecc27cfd4f2a35d45
BLAKE2b-256 checksum
How to use checksums
29882a26f6a2432614b5a7f411cdeb0eddb63bab27409d33923c768822123156
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for fitstitch 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fitstitch-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page