← All posts

3 min read

Writing a Zwift workout file without a spec

Coaches wanted a workout to land where the athlete actually rides. CadensIQ already writes FIT files for head units. Now it also writes .zwo for Zwift and .erg or .mrc for trainer apps. None of the three formats has a spec I could read.

Zwift publishes no spec

A .zwo file is XML. I followed a community reference built from the workouts bundled with Zwift, zwift-workout-file-reference. It lists the elements and shows power as a fraction of FTP. Even the unit of a duration is not stated anywhere. It is read from Zwift's own files: seconds.

The CompuTrainer files are older and stranger

.erg and .mrc are CompuTrainer course files. I could not find the original RacerMate spec, so I followed the reader in GoldenCheetah, which matches the files intervals.icu produces.

A file is a list of points: minutes from the start, then a target. Between two points the target moves in a straight line. Two points at the same minute make a step. That is how a ramp and a hard-edged interval end up in the same format.

Format30 s at 120-130%, then 15 s rest
.zwo30 s at 1.25 of FTP, 15 s at 0.4
.mrcpoints 0:00 125, 0:30 125, 0:30 40, 0:45 40 (% of FTP)
.ergthe same points at an FTP of 280 W: 350, 350, 112, 112
Output of the exporter for one step and one rest, not typed by hand.

What a trainer file cannot say

.zwo and .mrc hold percentages, so the app applies the athlete's own FTP. .erg holds watts, worked out from the FTP set in CadensIQ today. With no FTP set it answers with an error instead of guessing one.

Nobody has loaded one yet

The tests read all 52 library workouts back through parsers I wrote in the test. That shows the file says what the steps say. It does not show that Zwift or a trainer app accepts it. No trainer app has loaded these files yet, and the FIT files have not been on a head unit either.

If you try one, I would like to hear what your app made of it: hello@chainstay.app.