Workout export JSON format

The JSON file Health Exporter & Shortcuts writes when it exports workouts: entries, statistics, events, swim metrics, effort scores, GPS routes and heart rate samples, and the rules that keep it stable between versions.

Health Exporter & Shortcuts is a paid iPhone app: US$2.99 once on the App Store, which shows the price in your currency. No subscription and no in-app purchases.

Purpose #

Defines the JSON a workout export produces: its top-level shape, the fields on a workout entry and on its events, how statistics and sample series are keyed, the naming of the files, and the rules that keep the format usable by the automations built on top of it across versions.

Requirements #

Requirement: Workout JSON top-level structure #

The exported workout file SHALL be a dictionary with exactly two keys: exportInfo containing metadata, and workouts containing an array of workout entries.

Scenario: Export with workouts #

{
  "exportInfo": { ... },
  "workouts": [ ... ]
}

Scenario: No workouts in the date range #

Requirement: Workout export metadata header #

The exportInfo object SHALL contain:

Scenario: Metadata reflects export parameters #

{
  "exportDate": "2026-02-12T10:00:00Z",
  "startDate": "2026-02-05",
  "endDate": "2026-02-12",
  "activityTypes": ["running", "swimming"],
  "workoutCount": 2,
  "appVersion": "1.0.0",
  "buildNumber": "42"
}

Requirement: Types never authorized are listed #

The Export Workouts action in Shortcuts never asks for HealthKit authorization, because an automation has no screen to show the request on. It exports what the user has already allowed. When a type a workout export reads has never been offered to the user, typically because an update started reading it, exportInfo SHALL carry pendingAuthorizations: an array of the full HealthKit identifiers of those types, sorted ascending. A workout export reads workouts (HKWorkoutTypeIdentifier), their routes (HKWorkoutRouteTypeIdentifier), heart rate (HKQuantityTypeIdentifierHeartRate), swimming stroke counts (HKQuantityTypeIdentifierSwimmingStrokeCount) and, on iOS 18 or later, the two effort scores (HKQuantityTypeIdentifierWorkoutEffortScore and HKQuantityTypeIdentifierEstimatedWorkoutEffortScore), and the list is checked against all of them whatever the GPS Route option, since authorization is granted for the app and not per export.

The key SHALL be absent when no type is pending, and SHALL never be an empty array. Exports from the app itself never carry it, since the app asks before it exports. Written since 1.8.0; an export from an earlier version has no such key.

The data a pending type would have supplied is simply missing, exactly as it is for a type the user denied: no route, no heart rate series, no effort score, or with HKWorkoutTypeIdentifier pending no workouts at all. A type the user denied is not pending and is not listed: HealthKit does not tell an app which reads were denied.

Scenario: Shortcuts used before the app was ever opened #

"pendingAuthorizations": [
  "HKQuantityTypeIdentifierEstimatedWorkoutEffortScore",
  "HKQuantityTypeIdentifierHeartRate",
  "HKQuantityTypeIdentifierSwimmingStrokeCount",
  "HKQuantityTypeIdentifierWorkoutEffortScore",
  "HKWorkoutRouteTypeIdentifier",
  "HKWorkoutTypeIdentifier"
]

Before iOS 18 the list is the same without the two effort score identifiers.

Scenario: First run after the update that reads effort scores #

"pendingAuthorizations": [
  "HKQuantityTypeIdentifierEstimatedWorkoutEffortScore",
  "HKQuantityTypeIdentifierWorkoutEffortScore"
]

Scenario: Nothing pending #

Requirement: Workout entry format #

Each entry in the workouts array SHALL be a dictionary with:

Scenario: Running workout entry #

{
  "activityType": "running",
  "indoor": false,
  "startDate": "2026-02-10T07:15:00Z",
  "endDate": "2026-02-10T08:00:00Z",
  "duration": 2700,
  "statistics": { ... },
  "events": [ ... ],
  "source": "Apple Watch",
  "uuid": "1E8F5C0A-2B3D-4E5F-8A9B-0C1D2E3F4A5B"
}

Requirement: Activity type naming #

Activity type strings SHALL be stable, lowercase camelCase names derived from HKWorkoutActivityType. An activity type the app does not recognise, such as one introduced by a newer iOS SDK, SHALL be exported as unknown_<rawValue> rather than dropped.

Scenario: Unrecognised activity type #

Requirement: Workout statistics format #

The statistics object SHALL be keyed by the HealthKit quantity type identifier (for example HKQuantityTypeIdentifierActiveEnergyBurned). Each value SHALL contain a required unit string plus whichever of sum, average, min, and max are available. Aggregates that are not available SHALL be omitted from the JSON rather than written as null.

Scenario: Cumulative statistic #

Scenario: Discrete statistic #

Scenario: Workout with no statistics #

Requirement: Workout event format #

Each entry in the events array SHALL contain a type string (pause, resume, motionPaused, motionResumed, pauseOrResumeRequest, lap, segment, marker, or unknown) and a startDate ISO 8601 timestamp. endDate SHALL be present only for events that span a non-zero interval.

Scenario: Instantaneous event #

Requirement: Segment events are exported as recorded #

segment events SHALL be exported as HealthKit holds them, one per event, without being regrouped, relabelled or filtered.

On a run recorded by Apple Watch, the segments are its automatic splits, and there are two series of them: one split per kilometre and one per mile, each series starting when the workout starts. Both series are in the same events array, which is ordered by start date, so their splits are interleaved. The steps of a custom workout (warmup, intervals, cooldown) are not among them: see “Activities within a workout”. Other apps, and other workout types, can write segments that mean something else; a swim’s carry the metrics described in “Swim metrics on workout events”.

Nothing in a segment event says which series it belongs to, and the export does not tell them apart. A consumer that needs one series can measure the distance each segment covers along the workout’s route, from either a JSON-only export with the GPS route included or the GPX file of a JSON + GPX export: about 1,000 m for a kilometre split, about 1,609 m for a mile split. Without a route the only signal is duration: at a steady pace a mile split lasts about 1.6 times as long as a kilometre split, a difference that blurs when the pace changes a lot from one split to the next.

Scenario: Run with automatic splits #

Requirement: Activities within a workout #

A workout entry SHALL carry an activities array when HealthKit holds two or more activities (HKWorkoutActivity) for the workout, with one element per activity, ordered by start date ascending. The key SHALL be omitted when HealthKit holds one activity for the workout or none: a single activity spans the whole workout and would only repeat the entry. Written since 1.8.0; an export from an earlier version has no such key.

A workout holds several activities when it was recorded in parts. A multisport workout holds one per leg, such as swimming, transition, cycling, transition and running in a triathlon. A custom workout built on Apple Watch is expected to hold one per step: the warmup, each work and each recovery interval, and the cooldown.

Each element SHALL contain:

Nothing HealthKit documents on an activity says whether a step was a warmup, a work interval, a recovery or a cooldown, and the export SHALL NOT add a field that guesses it. The steps of a custom workout are expected to share the workout’s activity type, so a consumer tells them apart by their order, duration and statistics.

Events and routes are not split by activity: the workout’s events and its route cover all of its activities.

Scenario: Custom workout with intervals #

{
  "activityType": "running",
  "duration": 720,
  "endDate": "2026-02-10T07:12:00Z",
  "startDate": "2026-02-10T07:00:00Z",
  "statistics": {
    "HKQuantityTypeIdentifierDistanceWalkingRunning": { "sum": 2000, "unit": "m" },
    "HKQuantityTypeIdentifierHeartRate": { "average": 132.5, "max": 151, "min": 104, "unit": "count/min" }
  },
  "uuid": "0A1B2C3D-4E5F-4A6B-8C7D-9E0F1A2B3C4D"
}

Scenario: Triathlon #

Scenario: Workout recorded in one piece #

Requirement: Workout effort scores #

A workout entry SHALL carry effortScore when HealthKit relates a workout effort score (HKQuantityTypeIdentifierWorkoutEffortScore) to the workout, and estimatedEffortScore when it relates an estimated workout effort score (HKQuantityTypeIdentifierEstimatedWorkoutEffortScore). Each key SHALL be omitted when HealthKit relates no score of its kind to the workout: absent means not recorded, never 0, the same rule indoor follows. Written since 1.8.0, and only on iOS 18 or later, whose HealthKit introduced both types; an export from an earlier version of the app, or made on an earlier iOS, has neither key.

Both are JSON numbers on Apple’s workout effort scale, which runs from 1 to 10, read in HealthKit’s unitless effort unit (appleEffortScore) and written as HealthKit holds them, without rounding. The two are independent: a workout the user never rated can still carry Apple’s estimate, and neither is filled in from the other. When HealthKit relates more than one score of one kind to a workout, the most recent is exported; samples with identical dates are settled by a fixed rule, so repeated exports of the same data agree.

Both scores are read with the query HealthKit provides for the effort samples related to a workout. That it finds Apple’s estimate, and not only the user’s rating, is expected but not yet verified on a device.

The query names the workout and no activity, so it is expected to return the scores related to the workout as a whole. Whether HealthKit also returns a score it relates to one of the workout’s activities, which would then be exported as the workout’s, is not yet verified on a device.

Failing to read the scores of one workout costs that workout its scores and SHALL NOT fail the export, as for swimming stroke counts. The device being locked is the one exception: the export fails, as described in “A route that cannot be read is declared”.

Scenario: Rated workout #

Scenario: Workout the user did not rate #

Scenario: No score at all #

Requirement: Swim metrics on workout events #

Swimming events SHALL carry HKSWOLFScore when the event metadata provides a SWOLF score, and SwimmingStrokeCount when stroke samples overlap the event’s time window. Both keys SHALL be omitted when the corresponding data is absent.

Scenario: Swim segment with metrics #

Scenario: Bare lap without metrics #

Requirement: Workout ordering #

Workouts SHALL be ordered by start date ascending, and each workout’s events SHALL preserve their chronological order.

Scenario: Multiple workouts in range #

Requirement: Workout JSON encoding settings #

The JSON output SHALL use sorted keys and pretty printing, matching the health data export.

Scenario: JSON is human-readable #

Requirement: Workout file naming #

The exported file SHALL be named workouts_export_<timestamp>_<suffix>.json where <timestamp> is a Unix timestamp in seconds and <suffix> is an 8-character unique suffix. The file SHALL use UTF-8 encoding and application/json MIME type.

Scenario: File is created with correct name #

Requirement: Workout format stability across versions #

The workout JSON SHALL be covered by the “Format stability across versions” requirement of export-format.md, which holds the normative rules for both exports. Its golden fixture SHALL be HealthExporterTests/Fixtures/workout_export_golden.json, with workout_export_activities_golden.json beside it pinning activities and workout_export_effort_golden.json pinning effortScore and estimatedEffortScore.

Scenario: Event key renamed by accident #

Requirement: Workout entries carry a stable identifier #

Every object in the workouts array SHALL contain a uuid key holding the workout’s HealthKit UUID as a string. The field is always present, whether or not routes are exported.

Scenario: Any workout export #

Scenario: Duplicate workouts from multiple sources #

Requirement: Workout entries say whether the activity was indoors #

A workout entry SHALL carry an indoor boolean when HealthKit recorded HKMetadataKeyIndoorWorkout for that workout, and SHALL omit the key when HealthKit holds no such flag. The field is present whether or not routes are exported.

The activity type cannot carry this distinction: HealthKit has no indoor variant among its activity types, so an indoor cycle and a road ride are both cycling. Without indoor a consumer cannot tell a workout that happens to have no route from one that could never have had one.

Scenario: Indoor cycling session #

Scenario: Outdoor ride #

Scenario: Workout HealthKit never labelled #

Requirement: A route that cannot be read is declared #

When a workout has an HKWorkoutRoute that cannot be read, the entry SHALL carry routeUnavailable: true and SHALL NOT carry route or routeFile. The key SHALL be omitted in every other case, including for workouts that never had a route.

Without it, a route that failed while being read is indistinguishable from an indoor session: both produce an entry with no route, so the geography disappears and nothing says so.

Scenario: Route read fails partway through #

Scenario: The device locks while routes are read #

Scenario: Indoor workout #

Requirement: A route that yielded no points produces no file #

When routes are exported in JSON + GPX mode and a workout’s route yielded no usable points, the archive SHALL NOT contain a .gpx for it and the entry SHALL carry neither routeFile nor route.

A GPX holding a track with no points is rejected by the tools that read GPX, and an entry inside an archive is specified to carry routeFile and never route.

Scenario: Route with no fixes in archive mode #

Requirement: Embedded route object in JSON-only mode #

When routes are exported in JSON-only mode, a workout that has a route SHALL carry a route object containing pointCount (integer) and points (array). Each point SHALL contain the timestamp as an ISO 8601 string, latitude, longitude, altitude, speed, course, horizontal accuracy and vertical accuracy.

Scenario: Hike with a route #

Scenario: Indoor workout in the same export #

Requirement: Route file pointer in JSON + GPX mode #

When routes are exported in JSON + GPX mode, a workout that has a route SHALL carry a routeFile key holding the archive-relative path of its GPX file. The entry SHALL NOT carry a route object in this mode.

Scenario: Workout with a route in an archive #

Scenario: Joining JSON entries to route files #

Requirement: Raw heart rate samples in JSON-only mode #

When routes are exported in JSON-only mode, a workout SHALL carry its heart rate samples as recorded by HealthKit, each with its own native timestamp, inside a samples object. That object is a per-quantity container and SHALL therefore follow the existing requirement “Workout statistics format”, so its keys are the full HKQuantityTypeIdentifier... form. Each series SHALL declare its unit once beside its values array rather than on every element. The values SHALL NOT be aligned to route points, interpolated, or rounded.

Scenario: Hike exported as JSON #

Scenario: Key convention matches statistics #

Scenario: Fidelity of the values #

Scenario: Archive mode #

Scenario: Workout with no route #

Requirement: Route keys are mutually exclusive #

A workout entry SHALL never contain both route and routeFile.

Scenario: Either mode #

Requirement: JSON in an archive is unchanged by the packaging choice #

The workout JSON written inside a JSON + GPX archive SHALL be identical to the JSON that the same selection would produce with routes off, apart from the added routeFile pointers.

Scenario: Same selection exported both ways #

Requirement: Additive format evolution #

The additions above SHALL be purely additive. No existing key is renamed, moved, retyped or removed, so that consumers written against the current format keep working.

Scenario: Existing parser #

Requirement: Archive file naming #

An export in JSON + GPX mode SHALL produce a file named workouts_export_<timestamp>_<suffix>.zip, with <timestamp> and <suffix> as in “Workout file naming”, containing a JSON file with the same stem, workouts_export_<timestamp>_<suffix>.json.

Scenario: Archive export #

A complete example #

This is the file the app’s format test compares the encoder’s output against, byte for byte. Its values are invented, and it packs every shape a workout entry can take into one file except activities and the effort scores, which have scenarios of their own above, so it mixes things a real export keeps apart: the first workout carries its route inline, as the JSON only option writes it; the second points to a GPX file, as the JSON + GPX option writes it; the third declares a route that could not be read. For the same reason its workoutCount says 2 while it holds three workouts: in a real export, workoutCount is always the number of entries in workouts. Numbers are written unrounded and forward slashes are escaped, so count\/min is read back by any JSON parser as count/min.

{
  "exportInfo" : {
    "activityTypes" : [
      "running",
      "swimming"
    ],
    "appVersion" : "1.0.0",
    "buildNumber" : "42",
    "endDate" : "2026-02-12",
    "exportDate" : "2026-02-12T10:00:00Z",
    "startDate" : "2026-02-05",
    "workoutCount" : 2
  },
  "workouts" : [
    {
      "activityType" : "running",
      "duration" : 2700,
      "endDate" : "2026-02-10T08:00:00Z",
      "events" : [
        {
          "endDate" : "2026-02-10T07:42:00Z",
          "startDate" : "2026-02-10T07:40:00Z",
          "type" : "pause"
        },
        {
          "startDate" : "2026-02-10T07:42:00Z",
          "type" : "resume"
        },
        {
          "startDate" : "2026-02-10T07:50:00Z",
          "type" : "marker"
        }
      ],
      "indoor" : false,
      "route" : {
        "pointCount" : 3,
        "points" : [
          {
            "course" : 28.73,
            "ele" : 145.87,
            "hAcc" : 3.9100000000000001,
            "lat" : 45,
            "lon" : 9,
            "speed" : 1.0900000000000001,
            "t" : "2026-02-10T07:30:00Z",
            "vAcc" : 1.22
          },
          {
            "course" : 29.399999999999999,
            "ele" : 146.02000000000001,
            "hAcc" : 3.8799999999999999,
            "lat" : 45.000011999999998,
            "lon" : 9.0000070000000001,
            "speed" : 1.1100000000000001,
            "t" : "2026-02-10T07:30:01Z",
            "vAcc" : 1.2
          },
          {
            "course" : -1,
            "ele" : 146.19999999999999,
            "hAcc" : 3.8500000000000001,
            "lat" : 45.000025000000001,
            "lon" : 9.0000149999999994,
            "speed" : 1.1399999999999999,
            "t" : "2026-02-10T07:30:02Z",
            "vAcc" : 1.1799999999999999
          }
        ]
      },
      "samples" : {
        "HKQuantityTypeIdentifierHeartRate" : {
          "unit" : "count\/min",
          "values" : [
            {
              "t" : "2026-02-10T07:30:00Z",
              "value" : 142
            },
            {
              "t" : "2026-02-10T07:30:05Z",
              "value" : 145.5
            }
          ]
        }
      },
      "source" : "Apple Watch",
      "startDate" : "2026-02-10T07:15:00Z",
      "statistics" : {
        "HKQuantityTypeIdentifierActiveEnergyBurned" : {
          "sum" : 412.5,
          "unit" : "kcal"
        },
        "HKQuantityTypeIdentifierDistanceWalkingRunning" : {
          "sum" : 8210,
          "unit" : "m"
        },
        "HKQuantityTypeIdentifierHeartRate" : {
          "average" : 148.25,
          "max" : 179,
          "min" : 96,
          "unit" : "count\/min"
        }
      },
      "uuid" : "1E8F5C0A-2B3D-4E5F-8A9B-0C1D2E3F4A5B"
    },
    {
      "activityType" : "swimming",
      "duration" : 2100,
      "endDate" : "2026-02-11T18:35:00Z",
      "events" : [
        {
          "endDate" : "2026-02-11T18:12:00Z",
          "HKSWOLFScore" : 39.975000000000001,
          "startDate" : "2026-02-11T18:00:00Z",
          "SwimmingStrokeCount" : 56,
          "type" : "segment"
        },
        {
          "endDate" : "2026-02-11T18:24:00Z",
          "startDate" : "2026-02-11T18:12:00Z",
          "type" : "lap"
        }
      ],
      "indoor" : true,
      "routeFile" : "routes\/swimming-2026-02-11-7c2a9d31.gpx",
      "source" : "Apple Watch",
      "startDate" : "2026-02-11T18:00:00Z",
      "statistics" : {

      },
      "uuid" : "7C2A9D31-4F60-4B82-9E13-5A6B7C8D9E0F"
    },
    {
      "activityType" : "running",
      "duration" : 1800,
      "endDate" : "2026-02-12T06:30:00Z",
      "events" : [

      ],
      "indoor" : false,
      "routeUnavailable" : true,
      "source" : "Apple Watch",
      "startDate" : "2026-02-12T06:00:00Z",
      "statistics" : {

      },
      "uuid" : "9F1B4E67-3D28-4C05-A7B9-2E4F6A8C0D13"
    }
  ]
}

All format documents · Guides