HealthSave Get on the App Store

Export sleep data from Apple Watch

Sleep sits in Apple's export as HKCategoryTypeIdentifierSleepAnalysis records, one per stage segment, and the free converter turns them into a CSV with the stage name in the value column. For hours per night, select Sleep Stages in HealthSave's Export tab: it adds one sleep_total row for each night.

Where Apple's export file keeps sleep

A sleep record has no number. Its value names the stage, and its start and end times give the segment's length.

Record typeHKCategoryTypeIdentifierSleepAnalysis
Unitnone; the stage is the value
ValuesHKCategoryValueSleepAnalysisAsleepCore, HKCategoryValueSleepAnalysisAsleepDeep, HKCategoryValueSleepAnalysisAsleepREM, HKCategoryValueSleepAnalysisAwake, HKCategoryValueSleepAnalysisInBed, HKCategoryValueSleepAnalysisAsleepUnspecified
One record coversone segment of one stage, from startDate to endDate

Your iPhone can write In Bed records from your sleep schedule while Apple Watch writes the stages. Both land in the file, each with its own source.

Convert sleep in your browser

The free Apple Health to CSV converter reads your export.zip or export.xml on your own device, uploads nothing, and writes one CSV per record type with the columns startDate, endDate, value, unit and source.

Open the converter for Sleep Analysis records →

healthsave-sleep-analysis.csv
startDate,endDate,value,unit,source
2026-11-02 22:40:00 +0000,2026-11-03 06:50:00 +0000,HKCategoryValueSleepAnalysisInBed,,Example iPhone
2026-11-02 23:05:00 +0000,2026-11-03 00:20:00 +0000,HKCategoryValueSleepAnalysisAsleepCore,,Example Watch
2026-11-03 00:20:00 +0000,2026-11-03 01:05:00 +0000,HKCategoryValueSleepAnalysisAsleepDeep,,Example Watch
2026-11-03 01:05:00 +0000,2026-11-03 01:12:00 +0000,HKCategoryValueSleepAnalysisAwake,,Example Watch
2026-11-03 01:12:00 +0000,2026-11-03 02:00:00 +0000,HKCategoryValueSleepAnalysisAsleepREM,,Example Watch

Made by the converter from made-up readings. The unit column stays empty for sleep. The first row is the phone's In Bed span around the watch's stages.

The converter does not add durations. Subtract startDate from endDate in your spreadsheet, and leave the In Bed and Awake rows out when you add up sleep.

Export sleep with HealthSave on your iPhone

In HealthSave, open Export, set the dates, choose CSV or JSON, select Sleep Stages under Metrics, then tap the export button.

Metric columnsleep_core, sleep_deep, sleep_rem, sleep_awake, sleep_in_bed, sleep_asleep, plus sleep_total
Unit columnhours, rounded to two decimals
Stage rowsone per segment, dated at its start
sleep_total rowsone per night, with overlapping segments merged and Awake and In Bed left out
Which nighta segment that starts before noon counts toward the night before
HealthSave Export showing the From and To date controls and the CSV, JSON and PDF Report choices HealthSave Metrics with Sleep Stages selected for CSV export
Select Sleep Stages to include the sleep records that Apple Health has. HealthSave 1.9.9 (build 141), sample data.

CSV and JSON exports of up to seven calendar days are free, and longer ranges need Pro, a one-time purchase ($24.99 in the US).

The CSV columns are Date, Metric, Value, Unit, Source, Date (YYYY-MM-DD), Time (HH:MM:SS), Time Zone, then seven medication columns, which stay empty unless you export medications.

HealthSave has no account and no HealthSave cloud: your health data leaves the phone only in a file you export, a sync to a destination you set up, or Apple's cloud model for the Weekly Brief if you turn it on.

Limits of both files for sleep

Questions about exporting sleep

How do I get total hours slept per night?

Select Sleep Stages in HealthSave and filter the Metric column to sleep_total. Each row is one night with overlaps merged and Awake time left out. From the converter's CSV, add up the durations of the asleep rows for each night yourself.

What does AsleepUnspecified mean?

It marks sleep recorded with no stage. Some apps and older recordings write sleep this way.

Export sleep from your iPhone with HealthSaveGet on the App Store