What does the HealthSQL iPhone app write to iCloud Drive?
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:
v1/<day>-<number>.jsonl.deflate: JSON lines, compressed with raw deflate (in Python,zlib.decompress(data, -15)). A day's file grows during that day; an earlier day's file never changes. Read the files in name order.status.json: the phone's last export (last_sync, Unix seconds), the record count, the time zone, errors by type, and Health characteristics. On iOS 27, when the person shared only the recent past,limited_sincegives the earliest date the app may read.
A reader keeps one row per id. Reading a file twice changes nothing.
Lines
Each line has a kind, k:
k | What it is | Fields |
|---|---|---|
q | One quantity sample | t 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]). |
c | One category sample: a sleep stage, a mindful session, a symptom | As q; v is Health's category value |
w | One workout | activity, duration (seconds), stats by Health type (sum, avg, min, max, u), events, activities, m |
route | The GPS route of a workout | points: [time, lat, lon, altitude, speed, accuracy] |
mind | A State of Mind entry | kind, valence, labels, associations |
ecg | An ECG summary, without voltages | classification, avgHeartRate, hz, n |
rings | One day of Activity rings; its id is the date | day, moveKcal, moveGoalKcal, exerciseMin, exerciseGoalMin, standHours, standGoalHours |
del | A record deleted on the phone | id. The id stays deleted even if its record arrives later. |
days | Starts a run of day totals for one type | t, from, to (dates). The reader drops this type's totals in the range, then takes the day lines that follow. |
day | Health's own total for one day of one quantity type | t, 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.