Health export JSON format

The JSON file Health Exporter & Shortcuts writes when it exports Apple Health data: its keys, units, dates and sleep stages, 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 structure of the exported JSON file: the top-level shape, the export metadata header, daily entries, the sleep stage breakdown, date ordering, encoder settings, and the exported file’s name.

Requirements #

Requirement: JSON top-level structure #

The exported JSON file SHALL be a dictionary with an exportInfo key containing metadata, plus one key per exported data type containing an array of daily entries.

Scenario: Export with two data types #

{
  "exportInfo": { ... },
  "stepCount": [ ... ],
  "restingHeartRate": [ ... ]
}

Scenario: Data type with no data #

Scenario: Data type the iOS version does not have #

Requirement: Export metadata header #

The exportInfo object SHALL contain:

Scenario: Metadata reflects export parameters #

{
  "exportDate": "2026-02-07T15:30:00Z",
  "startDate": "2026-02-01",
  "endDate": "2026-02-07",
  "dataTypes": ["stepCount", "weight"],
  "appVersion": "1.0.0",
  "buildNumber": "42",
  "measurementSystem": "metric"
}

Scenario: Measurement system follows the device locale #

Requirement: Types never authorized are listed #

The Export Health Data 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 it exports 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 (for example HKQuantityTypeIdentifierHeartRateVariabilitySDNN), sorted ascending.

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.

A pending type keeps its key in the file, with an empty array, like any type with no data. A type the user denied is not pending and is not listed: HealthKit does not tell an app which reads were denied.

Scenario: A new type read from an automation #

"pendingAuthorizations": ["HKQuantityTypeIdentifierHeartRateVariabilitySDNN"]

Scenario: Nothing pending #

Requirement: Daily entry format #

Each entry in a data type’s array SHALL be a dictionary with at least these three keys:

Entries for non-sleep data types SHALL carry these three keys and nothing else. sleepTime adds stages, per the requirement below.

Scenario: Step count entry #

{ "value": 8432, "date": "2026-02-10", "unit": "count" }

Scenario: Resting heart rate entry #

{ "value": 63, "date": "2026-02-10", "unit": "bpm" }

Requirement: Heart rate variability, SDNN and RMSSD #

HealthKit records heart rate variability as two separate measures, and the export keeps them under two separate keys. Both SHALL use the daily entry format above, with unit "ms" (milliseconds) on every measurement system, and value the average of the samples HealthKit holds for that day. A day with no sample SHALL have no entry, never a zero.

On an iOS earlier than 27 the app does not list RMSSD and an export of every type does not include it. The Export Health Data action in Shortcuts still offers it, because Shortcuts cannot hide an option on one iOS version; an action that selects it there exports the other types it selects, and leaves RMSSD out of the file and out of pendingAuthorizations. An action that selects only RMSSD there has nothing to export: it SHALL fail without writing a file, with a message that names the type and the iOS version it needs.

Scenario: Both measures on the same day #

"heartRateVariability": [ { "value": 38.25, "date": "2026-11-12", "unit": "ms" } ],
"heartRateVariabilityRMSSD": [ { "value": 31.5, "date": "2026-11-12", "unit": "ms" } ]

Scenario: A shortcut that selects RMSSD on an earlier iOS #

Scenario: A shortcut that selects only RMSSD on an earlier iOS #

Requirement: Sleep entries include stage breakdown #

Each entry in the sleepTime array SHALL include an additional stages object with per-stage durations in minutes:

The value field SHALL remain the sum of core + deep + rem only, preserving backward compatibility.

Scenario: Sleep entry with stage breakdown #

{
  "value": 417.625,
  "date": "2026-02-08",
  "unit": "min",
  "stages": {
    "core": 244.5,
    "deep": 77.25,
    "rem": 95.875,
    "awake": 14.5,
    "unspecified": 0
  }
}

Scenario: Non-sleep entries do not include stages #

Requirement: Date ordering #

Entries within each data type’s array SHALL be ordered chronologically (oldest date first).

Scenario: Multi-day export ordering #

Requirement: JSON encoding settings #

The JSON output SHALL use sorted keys for consistent output and SHALL use pretty-printing (indented) for human readability.

Scenario: JSON is human-readable #

Requirement: File naming #

The exported file SHALL be named health_export_<timestamp>_<suffix>.json where <timestamp> is a Unix timestamp in seconds and <suffix> is an 8-character unique suffix that keeps concurrent exports from overwriting each other. The file SHALL use UTF-8 encoding and application/json MIME type.

Scenario: File is created with correct name #

Scenario: Two exports in the same second #

Requirement: Format stability across versions #

The exported JSON SHALL be treated as a public contract, because users build Apple Shortcuts automations on top of its keys and receive no migration path. Between released versions the app SHALL only add top-level keys, data type keys, or optional entry fields. Renaming a key, removing a key, changing a value’s type or unit, or changing a date format SHALL require an explicit decision, an update to this spec, and a note in the release notes.

The repository SHALL keep committed golden fixtures of the encoded output and SHALL compare the encoder’s output against them byte for byte, so that any change to the format appears as a reviewable diff rather than as a silent behaviour change.

Scenario: A key is renamed by accident #

Scenario: A new optional field is added #

A complete example #

This is the file the app’s format test compares the encoder’s output against, byte for byte, so it is exactly what an export looks like. Its values are invented. Two details are deliberate: numbers are written unrounded, so 63.1 appears as 63.100000000000001, which any JSON parser reads back as 63.1; and vo2Max, selected but with no data in the range, is an empty array.

{
  "exportInfo" : {
    "appVersion" : "1.0.0",
    "buildNumber" : "42",
    "dataTypes" : [
      "stepCount",
      "weight",
      "sleepTime",
      "restingHeartRate",
      "vo2Max"
    ],
    "endDate" : "2026-02-10",
    "exportDate" : "2026-02-10T18:30:00Z",
    "measurementSystem" : "metric",
    "startDate" : "2026-02-07"
  },
  "restingHeartRate" : [
    {
      "date" : "2026-02-09",
      "unit" : "bpm",
      "value" : 63.100000000000001
    }
  ],
  "sleepTime" : [
    {
      "date" : "2026-02-08",
      "stages" : {
        "awake" : 14.5,
        "core" : 244.5,
        "deep" : 77.25,
        "rem" : 95.875,
        "unspecified" : 0
      },
      "unit" : "min",
      "value" : 417.625
    }
  ],
  "stepCount" : [
    {
      "date" : "2026-02-07",
      "unit" : "count",
      "value" : 8432
    },
    {
      "date" : "2026-02-08",
      "unit" : "count",
      "value" : 10250
    },
    {
      "date" : "2026-02-09",
      "unit" : "count",
      "value" : 6117
    }
  ],
  "vo2Max" : [

  ],
  "weight" : [
    {
      "date" : "2026-02-09",
      "unit" : "kg",
      "value" : 72.25
    }
  ]
}

All format documents · Guides