What does the HealthSQL iPhone app write to iCloud Drive?

Updated

Compressed JSON lines, one line per Health record, in the app's folder in your iCloud Drive, plus a status.json with the time of the last export. On a Mac the folder is ~/Library/Mobile Documents/iCloud~dkbuilds~HealthSQL/Documents, and the healthsql command reads it into SQLite; you never need to read the files yourself.

HealthSQL is an iPhone app and a command-line tool that copy your whole Apple Health record into a local SQLite database on your computer, so AI agents can query it with SQL or MCP. This page is the contract between the iPhone app and any reader of its files, for people who want to write their own.

The files

In the app's Documents/ folder:

A reader keeps one row per id. Reading a file twice changes nothing.

Lines

Each line has a kind, k:

kWhat it isFields
qOne quantity samplet Health type, id, s and e (start and end, Unix seconds), v value, u unit, src and srcName (the app or device that wrote it), dev, m metadata. A sample that holds many values adds n, min, max and series ([time, value]).
cOne category sample: a sleep stage, a mindful session, a symptomAs q; v is Health's category value
wOne workoutactivity, duration (seconds), stats by Health type (sum, avg, min, max, u), events, activities, m
routeThe GPS route of a workoutpoints: [time, lat, lon, altitude, speed, accuracy]
mindA State of Mind entrykind, valence, labels, associations
ecgAn ECG summary, without voltagesclassification, avgHeartRate, hz, n
ringsOne day of Activity rings; its id is the dateday, moveKcal, moveGoalKcal, exerciseMin, exerciseGoalMin, standHours, standGoalHours
delA record deleted on the phoneid. The id stays deleted even if its record arrives later.
daysStarts a run of day totals for one typet, from, to (dates). The reader drops this type's totals in the range, then takes the day lines that follow.
dayHealth's own total for one day of one quantity typet, day, and sum (a type that adds up) or avg, min, max (one that does not), u

Why day lines exist

Several devices record the same activity. Say that on one day a Watch counts 9,420 steps, an iPhone 8,870 and a ring 9,610, mostly for the same walking (an example, not real data). A sum of the raw samples gives 27,900. Only Health knows which source counts for which minute, so the phone asks Health for each day's statistics, the numbers the Health app shows, and writes them as day lines. After new or deleted records of a type, the phone asks again from the earliest day that changed and writes that range again.

A reader must use day lines for any daily number, and raw samples for a value at a time of day or for one source's own numbers. More on double counting.

Units

A unit comes from the quantity type, as Health names it, and never from the phone's region: lengths are m, body mass kg, energy kcal, temperature degC, speed m/s, volume mL. A percent is a 0-1 fraction. Every line that has a value carries its unit.

Gaps and changes

The phone keeps one anchor (HealthKit's bookmark) per type and asks for everything after it, so a gap of an hour or a month fills the same way. An anchor moves only after its lines are in a file. When the meaning of a line changes, the app raises its revision: each phone then drops its anchors and files and exports again from the start, and a reader replaces each record by its id.

Not in the export

Clinical records (they need a separate permission from Apple), medications and vision prescriptions (iOS asks about each one), ECG voltages, heartbeat series and audiograms.