Markdown export format

The Markdown file Health Exporter & Shortcuts writes, from version 1.8.0, when you pick Markdown instead of JSON: the same data as compact tables, for pasting into an AI assistant, 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 Markdown file the app writes when the user picks Markdown instead of JSON: the preamble, how each health data type becomes a table, how sleep stages are shown, how a workout is laid out, how numbers are rounded and text is escaped, and what is deliberately left out. Markdown is offered from version 1.8.0, for handing an export to an AI assistant: the data is the same as in the JSON, without the keys repeated on every value.

The data itself is specified by export-format.md for health data and workout-export-format.md for workouts. Every figure in a Markdown export is a figure from the JSON the same export would have produced, rounded as described below, and every date and timestamp is the same string. The Markdown adds one thing the JSON does not carry, the time zone line, and leaves out what “What the format does not carry” lists.

Requirements #

Requirement: Markdown is chosen in the app only #

The app SHALL offer a choice between JSON and Markdown on both the Health Data and the Workouts tabs, with JSON selected until the user picks otherwise. Each tab SHALL keep its own choice, and neither SHALL be remembered between launches.

The Export Health Data and Export Workouts actions in Shortcuts SHALL keep returning JSON, with no parameter to choose a format.

Scenario: Nothing chosen #

Scenario: An automation #

Requirement: Fixed English text #

Every heading, label, column name and sentence the format writes SHALL be the English text this document specifies, whatever the language of the device that wrote the file. Like the JSON keys, it is a format, not user interface, and an export SHALL read the same on every device.

Scenario: Italian device #

Requirement: Encoding and lines #

The file SHALL be UTF-8, SHALL separate lines with a single line feed, and SHALL end with one line feed. Sections SHALL be separated by one empty line. Tables SHALL be GitHub Flavored Markdown tables, with numeric columns right aligned.

Requirement: Text is escaped for tables and lists #

Text copied from the document, such as a source name, a type or a unit, SHALL be written as the JSON holds it, except that every | SHALL be written \|, so that it cannot split a table cell, and every run of line breaks SHALL be replaced by a single space, or dropped at the start or the end of the text, so that it cannot end a list item or a table row early. A parser that wants the JSON string back must undo the first: \| is |. The second cannot be undone. In practice only a source name, which is whatever the recording app called itself, can hold either.

Scenario: A source name with a pipe and a line break #

Requirement: Health data preamble #

A health data export SHALL open with the heading # Apple Health export: daily data, followed by a list carrying the fields of the JSON exportInfo, and the time zone:

- Range: 2026-02-07 through 2026-02-10 (inclusive)
- Data types: stepCount, weight, sleepTime, restingHeartRate, vo2Max
- Measurement system: metric
- Exported: 2026-02-10T18:30:00Z
- Time zone: Europe/Rome (UTC+01:00 at export)
- App: Health Exporter & Shortcuts 1.0.0 (build 42)

Range is startDate through endDate, both days included, Data types is dataTypes in its order, or none when it is empty, Measurement system is measurementSystem, Exported is exportDate, and App carries appVersion and buildNumber. Each value is written exactly as the JSON holds it. Time zone is described in “The time zone is stated”.

A paragraph SHALL follow the list, saying that there is one table per data type in the order listed, one row per day that has data, oldest first, that dates are calendar days in the time zone above, and how numbers are rounded.

Scenario: Preamble of an export #

Requirement: The time zone is stated #

Both preambles SHALL carry a Time zone line, after Exported, naming the time zone of the device when it exported: its identifier as iOS reports it, normally an IANA name such as Europe/Rome, followed by its offset from UTC at exportDate, as UTC+hh:mm or UTC-hh:mm:

- Time zone: Europe/Rome (UTC+01:00 at export)

The line exists in the Markdown only: neither JSON document records the time zone, and this format does not add it there. It is what makes the dates readable. The daily tables are bucketed by calendar day in this zone, and workout timestamps are in UTC, so without it a question such as “what did I do last Tuesday evening” can land on the wrong day. The offset is the one in force at export, and a timestamp from another season needs the zone’s own rules rather than that offset, which is why the workout paragraph tells the reader to apply them. The zone is the device’s at export, which is not necessarily where a workout was recorded or a day was lived if the person travelled.

The offset SHALL be left out, leaving the identifier alone, when exportDate is not an ISO 8601 timestamp, which no export from the app produces.

Scenario: Summer in Rome #

Requirement: Types never authorized are named #

When the document carries pendingAuthorizations, the preamble list SHALL end with a line naming them, in words, rather than leaving those types looking as if they had no data:

- Pending authorization: HKQuantityTypeIdentifierHeartRateVariabilitySDNN. Access to these was never requested, so their data is missing from this export rather than absent from Health.

The line SHALL be absent when nothing is pending. Only a Shortcuts export can have pending types, and Shortcuts returns JSON, so a Markdown export from the app does not carry this line in practice. The requirement holds for any document the format renders.

Scenario: Nothing pending #

Requirement: One table per health data type #

Each type in Data types SHALL get a section headed ## <key>, where <key> is the type’s JSON key, in the order of Data types. A type with entries SHALL get a table with two columns: Date, holding the entry’s date, and a value column whose header names how the day’s value was made and its unit:

JSON aggregationHeader
sum of the day’s samplesTotal (<unit>)
average of the day’s samplesAverage (<unit>)
most recent sample of the dayLatest (<unit>)
a key the app does not knowValue (<unit>)

<unit> is the unit the entries carry, which follows the measurement system. The unit SHALL appear in the header only, never beside a value. Rows SHALL follow the entries’ order, oldest first, one per entry. Every key the app writes is a type it knows; Value exists so that a document from a newer version still renders without claiming how its value was made.

Scenario: Step count #

## stepCount

| Date | Total (count) |
|---|---:|
| 2026-02-07 | 8432 |
| 2026-02-08 | 10250 |

Scenario: US measurement system #

Requirement: Percentages are stated as fractions #

HealthKit, and so the JSON, holds a percentage as a fraction of 1 with the unit %: an oxygen saturation of 97% is 0.97. Wherever the format writes a unit and that unit is %, in the header of a daily table, in the Unit cell of a workout statistic or in the header of an activity column, it SHALL write fraction, 1 = 100% in its place, so that 0.97 cannot be read as less than one percent. The values SHALL be the JSON values, never multiplied.

Scenario: Oxygen saturation #

Requirement: A type with no data says so #

A type in Data types with no entries SHALL get its section, with the sentence No data in this range. in place of a table. When no type has data, every section says so, so an empty export reads as empty rather than as broken.

Scenario: VO2 max with no data #

Requirement: Sleep stages are columns #

The sleepTime table SHALL have seven columns: Date, then Core + deep + REM, Core, Deep, REM, Awake and Unspecified, each followed by the unit in parentheses. The second column is the JSON value, the others are the fields of stages. A sentence SHALL precede the table, saying that each night is filed under the day it ended, and that unspecified sleep, recorded without stages, and awake time are not counted in the first column. An entry without stages, which the app does not write, SHALL keep its row with the five stage cells empty.

The first column is headed by what it adds up rather than as “asleep”, because a night recorded without stages lands entirely in Unspecified and leaves the first column at 0.

Scenario: A night with stages #

| Date | Core + deep + REM (min) | Core (min) | Deep (min) | REM (min) | Awake (min) | Unspecified (min) |
|---|---:|---:|---:|---:|---:|---:|
| 2026-02-08 | 417.63 | 244.5 | 77.25 | 95.88 | 14.5 | 0 |

Requirement: Workout preamble #

A workout export SHALL open with the heading # Apple Health export: workouts, followed by a list carrying the fields of the JSON exportInfo, and the time zone:

- Range: 2026-02-05 through 2026-02-12 (inclusive)
- Activity types: running, swimming
- Workouts: 2
- Exported: 2026-02-12T10:00:00Z
- Time zone: Europe/Rome (UTC+01:00 at export)
- App: Health Exporter & Shortcuts 1.0.0 (build 42)

Activity types is activityTypes, or none when it is empty, and Workouts is workoutCount. The Pending authorization line of the health preamble applies here too. A paragraph SHALL follow, saying that there is one section per workout, oldest first, that timestamps are ISO 8601 in UTC, that local times come from converting them to the time zone above with its daylight saving rules at each timestamp rather than the offset at export, that a duration is active time in seconds without pauses, how numbers are rounded, and that GPS routes and the samples recorded along them are not written in Markdown.

When there are no workouts, the paragraph SHALL be followed by No workouts in this range.

Requirement: One section per workout #

Each workout SHALL get a section headed ## <activityType>, <startDate>, in the order of the JSON workouts array, followed by a list:

An effort score the JSON omits SHALL have no line, never 0 or none: absent means not recorded, as in the JSON. A score is a number like any other and is rounded as below.

Then, each preceded by an empty line and only when there is something to put in it: the statistics table, the activities table and the events table, in that order.

Scenario: A run #

## running, 2026-02-10T07:15:00Z

- End: 2026-02-10T08:00:00Z
- Duration: 2700 s
- Indoor: no
- Effort (user rating, 1-10): 7
- Effort (Apple's estimate, 1-10): 6
- Source: Apple Watch
- UUID: 8C9DAEBF-C0D1-42E3-A4F5-7A8B9CADBECF

Requirement: Workout statistics are a table #

A workout with statistics SHALL carry a table with the columns Statistic, Unit, Total, Average, Min and Max, one row per statistic. Statistic is the JSON key without the HKQuantityTypeIdentifier prefix, so HKQuantityTypeIdentifierHeartRate is HeartRate, and putting the prefix back gives the JSON key; every key the app writes carries it, and a key that did not would be written whole. Total is the JSON sum. An aggregate the JSON omits SHALL be an empty cell.

Rows SHALL be ordered ascending by the full JSON key, compared by Unicode code point. That order is the tie-break as well as the rule: two keys that shorten to the same name can never swap places between two exports of the same data.

Scenario: A run’s statistics #

| Statistic | Unit | Total | Average | Min | Max |
|---|---|---:|---:|---:|---:|
| ActiveEnergyBurned | kcal | 412.5 |  |  |  |
| DistanceWalkingRunning | m | 8210 |  |  |  |
| HeartRate | count/min |  | 148.25 | 96 | 179 |

Requirement: Workout activities are a table #

A workout whose JSON entry carries activities SHALL carry a table with one row per activity, in the JSON order, and SHALL carry none when the key is absent. The first four columns are Activity, Start, End and Duration (s), holding the activity’s activityType, startDate, endDate and duration, with an empty End cell for an activity the JSON gives no endDate.

The activities’ statistics follow as further columns of the same table, one per statistic, unit and aggregate that at least one activity carries, headed <Statistic> <Aggregate> (<unit>): <Statistic> is shortened as in the statistics table, <Aggregate> is Total, Average, Min or Max, and <unit> is the statistic’s unit. An activity without that statistic or aggregate SHALL have an empty cell. The columns SHALL be ordered by full JSON key, compared by Unicode code point, then by unit, then in the order Total, Average, Min, Max.

The statistics are columns rather than a second table because an activity has no name to join a second table on: the steps of a custom workout all share the workout’s activity type, so only the row can say which activity a figure belongs to. A statistic recorded in two units, which HealthKit does not produce, would get a set of columns for each.

Scenario: A run in four steps #

| Activity | Start | End | Duration (s) | DistanceWalkingRunning Total (m) | HeartRate Average (count/min) | HeartRate Min (count/min) | HeartRate Max (count/min) |
|---|---|---|---:|---:|---:|---:|---:|
| running | 2026-02-10T07:00:00Z | 2026-02-10T07:12:00Z | 720 | 2000 | 132.5 | 104 | 151 |
| running | 2026-02-10T07:12:00Z | 2026-02-10T07:13:30Z | 90 | 400 | 171.25 | 152 | 183 |
| running | 2026-02-10T07:13:30Z | 2026-02-10T07:16:00Z | 150 | 400 | 148.75 | 139 | 170 |
| running | 2026-02-10T07:16:00Z |  | 0 | 1100 | 136 | 128 | 149 |

Requirement: Workout events are a table #

A workout with events SHALL carry a table with the columns Event, Start and End, one row per event in the JSON order, holding type, startDate and endDate, with an empty cell where the JSON has no endDate. When any event of the workout carries a swim metric, the table SHALL add SWOLF and Strokes, holding HKSWOLFScore and SwimmingStrokeCount, with empty cells where an event has none.

Event times are the JSON timestamps, deliberately, rather than offsets from the workout’s start, which would be shorter: the same string in both formats matters more than the characters saved.

Scenario: A swim #

| Event | Start | End | SWOLF | Strokes |
|---|---|---|---:|---:|
| segment | 2026-02-11T18:00:00Z | 2026-02-11T18:12:00Z | 39.98 | 56 |
| lap | 2026-02-11T18:12:00Z | 2026-02-11T18:24:00Z |  |  |

Requirement: Routes are left out, and said to be #

GPS routes and sample series SHALL never be written in Markdown: a route is thousands of coordinates, and GPX exists for it. When Markdown is chosen in the app, the Route options SHALL not be offered, a line SHALL say that Markdown leaves routes out, and no route SHALL be read.

A workout whose JSON entry carries any route information, route, routeFile or routeUnavailable, SHALL say so with one line in its list, the same for all three:

- Route: recorded, not in this file

Since the app reads no route for a Markdown export, none of these keys reaches a Markdown export from the app, and the line describes what the format does with any document it is given. It never points at a GPX file, which a Markdown export does not include.

Scenario: Markdown chosen on the Workouts tab #

Requirement: Numbers are rounded the way a person writes them #

Every number SHALL be rounded half away from zero to at most 2 decimal places, or 3 when its magnitude is below 1, starting from the shortest decimal that reads back as the JSON value. Trailing zeros SHALL be dropped, a whole number SHALL have no decimal point, there SHALL be no thousands separator and no exponent, the decimal separator SHALL be a period whatever the device’s locale, and a value that rounds to zero SHALL be written 0, without a sign.

The precision follows each number’s own magnitude, so one column can mix two and three decimal places, such as 0.973 above 1.05. That is deliberate: a fraction below 1 is where percentages live, and two places would round 97.25% to 97%.

A value that is not finite SHALL make the export fail, as it does for the JSON, which cannot hold it either: an error is reported and no file is written.

Scenario: Values from the JSON #

Requirement: What the format does not carry #

A Markdown export SHALL NOT carry GPS routes, the sample series exported with a route, or the raw sleep samples of a debug build, which are not read at all when Markdown is chosen. Everything else in the JSON is present, and the time zone line is the one thing present that the JSON does not carry.

Requirement: File naming #

The exported file SHALL be named as its JSON counterpart with the extension .md: health_export_<timestamp>_<suffix>.md for health data and workouts_export_<timestamp>_<suffix>.md for workouts, with <timestamp> and <suffix> as in the JSON documents.

Scenario: Health data as Markdown #

Requirement: Format stability across versions #

The Markdown SHALL be held to the “Format stability across versions” requirement of export-format.md, from the first release that ships it: people write instructions for their assistant against its headings and columns, and a reworded header breaks those as surely as a renamed key breaks an automation.

Between released versions the format SHALL only grow at its ends: a new column at the right end of a table, a new line at the end of a list, a new table or section after the existing ones. Renaming, removing or reordering what exists, adding anything in the middle of a table or a list, or changing how numbers are rounded or text is escaped, SHALL require an explicit decision, an update to this document, and a note in the release notes. A consumer SHALL find a column by its header text rather than by its position, and a line by its label, so that an addition never breaks it. That is also how the statistic columns of an activities table are found, since which of them a table has depends on the data, not on the version.

The golden fixtures SHALL be compared byte for byte, and re-recorded only through the .actual flow.

Scenario: A field is added to workouts #

A complete example: health data #

This is the file the app’s format test compares the Markdown output against, byte for byte, rendered from the same invented values as the health export JSON example, so the two can be read side by side. 63.100000000000001 in the JSON is 63.1 here, and the sleep entry’s value and stages are one row. The Time zone line is the one line the JSON has no counterpart for.

# Apple Health export: daily data

- Range: 2026-02-07 through 2026-02-10 (inclusive)
- Data types: stepCount, weight, sleepTime, restingHeartRate, vo2Max
- Measurement system: metric
- Exported: 2026-02-10T18:30:00Z
- Time zone: Europe/Rome (UTC+01:00 at export)
- App: Health Exporter & Shortcuts 1.0.0 (build 42)

One table per data type, in the order listed above, with one row per day that has data, oldest first. Dates are calendar days in the time zone above. Numbers are rounded to at most 2 decimal places, 3 for numbers smaller than 1.

## stepCount

| Date | Total (count) |
|---|---:|
| 2026-02-07 | 8432 |
| 2026-02-08 | 10250 |
| 2026-02-09 | 6117 |

## weight

| Date | Latest (kg) |
|---|---:|
| 2026-02-09 | 72.25 |

## sleepTime

Each night is filed under the day it ended. Unspecified is sleep recorded without stages; neither it nor awake time is counted in the first column.

| Date | Core + deep + REM (min) | Core (min) | Deep (min) | REM (min) | Awake (min) | Unspecified (min) |
|---|---:|---:|---:|---:|---:|---:|
| 2026-02-08 | 417.63 | 244.5 | 77.25 | 95.88 | 14.5 | 0 |

## restingHeartRate

| Date | Average (bpm) |
|---|---:|
| 2026-02-09 | 63.1 |

## vo2Max

No data in this range.

A complete example: workouts #

Rendered from the same invented values as the workout export JSON example, which packs every route shape a workout can take into one file, and like it leaves activities and effort scores to the scenarios above. Each of its three workouts carries route information of a different kind, a route, a route file and a route that could not be read, and each gets the same line, Route: recorded, not in this file. An export from the app reads no route when you pick Markdown, so in practice that line does not appear. For the same reason as in the JSON example, Workouts says 2 above three workouts; in a real export it is always the number of sections.

# Apple Health export: workouts

- Range: 2026-02-05 through 2026-02-12 (inclusive)
- Activity types: running, swimming
- Workouts: 2
- Exported: 2026-02-12T10:00:00Z
- Time zone: Europe/Rome (UTC+01:00 at export)
- App: Health Exporter & Shortcuts 1.0.0 (build 42)

One section per workout, oldest first, headed by its activity type and start. Timestamps are ISO 8601 in UTC. For local times, convert them to the time zone above, applying its daylight saving rules at each timestamp rather than the offset at export. A duration is active time in seconds, without pauses. Numbers are rounded to at most 2 decimal places, 3 for numbers smaller than 1. GPS routes and the samples recorded along them are not written in Markdown: export as JSON with the GPS route option on to get them.

## running, 2026-02-10T07:15:00Z

- End: 2026-02-10T08:00:00Z
- Duration: 2700 s
- Indoor: no
- Source: Apple Watch
- UUID: 1E8F5C0A-2B3D-4E5F-8A9B-0C1D2E3F4A5B
- Route: recorded, not in this file

| Statistic | Unit | Total | Average | Min | Max |
|---|---|---:|---:|---:|---:|
| ActiveEnergyBurned | kcal | 412.5 |  |  |  |
| DistanceWalkingRunning | m | 8210 |  |  |  |
| HeartRate | count/min |  | 148.25 | 96 | 179 |

| Event | Start | End |
|---|---|---|
| pause | 2026-02-10T07:40:00Z | 2026-02-10T07:42:00Z |
| resume | 2026-02-10T07:42:00Z |  |
| marker | 2026-02-10T07:50:00Z |  |

## swimming, 2026-02-11T18:00:00Z

- End: 2026-02-11T18:35:00Z
- Duration: 2100 s
- Indoor: yes
- Source: Apple Watch
- UUID: 7C2A9D31-4F60-4B82-9E13-5A6B7C8D9E0F
- Route: recorded, not in this file
- Statistics: none

| Event | Start | End | SWOLF | Strokes |
|---|---|---|---:|---:|
| segment | 2026-02-11T18:00:00Z | 2026-02-11T18:12:00Z | 39.98 | 56 |
| lap | 2026-02-11T18:12:00Z | 2026-02-11T18:24:00Z |  |  |

## running, 2026-02-12T06:00:00Z

- End: 2026-02-12T06:30:00Z
- Duration: 1800 s
- Indoor: no
- Source: Apple Watch
- UUID: 9F1B4E67-3D28-4C05-A7B9-2E4F6A8C0D13
- Route: recorded, not in this file
- Statistics: none
- Events: none

All format documents · Guides