How to export iPhone Health data to CSV and analyze it

Export iPhone Health data to CSV and analyze it

Your iPhone and Apple Watch record a huge amount of data every day: heart rate, steps, sleep, blood oxygen and more. This guide is for anyone who finds the charts in the Health app aren’t enough and wants to crunch the numbers themselves.

It works just as well for organizing research data as for browsing your own records.

Step 1: Export all your data from the Health app

  1. Open the Health app on your iPhone
  2. Tap the round profile picture in the top-right corner
  3. Near the bottom, tap Export All Health Data
  4. Wait for the export to finish (this can take anywhere from a few minutes to more than ten, depending on how much data you have)
  5. When the share sheet opens, use AirDrop, Mail or another option to send the file to your Mac

The export is a Zip file. Double-click it to unzip it, and you’ll get a folder named apple_health_export containing export.xml. That’s the file that matters. If you’ve taken ECG recordings, you’ll also find CSV files, and if your workouts have GPS routes, GPX files.

Step 2: What to do with export.xml

This is where a lot of people get stuck. export.xml uses Apple’s own XML format, and it’s huge. With a few years of records, it’s not unusual for it to run to several hundred MB or even more than 1 GB. Excel and Numbers can’t open it as is.

You have two options.

Option A: Write your own script

In Python, use iterparse, which processes one record at a time instead of loading everything into memory.

import csv
import xml.etree.ElementTree as ET

with open("records.csv", "w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow(["type", "sourceName", "unit", "startDate", "endDate", "value"])
for _, elem in ET.iterparse("export.xml", events=("end",)):
if elem.tag == "Record":
w.writerow([
elem.get("type"), elem.get("sourceName"), elem.get("unit"),
elem.get("startDate"), elem.get("endDate"), elem.get("value"),
])
elem.clear() # free memory (forget this and it will crash)

To narrow it down to certain types, filter on elem.get("type") (HKQuantityTypeIdentifierStepCount for steps, HKQuantityTypeIdentifierHeartRate for heart rate).

  • Best for: people who can code and want fine-grained control over what gets extracted
  • Note: if you forget elem.clear(), the script runs out of memory and crashes. Workouts and sleep use tags other than Record, so handle them separately if you need them

Option B: Use a conversion app

If you’d rather not write code, a dedicated app is the shortcut.

Our own HealthKit Parser is a Mac app built for exactly this job.

  1. Open HealthKit Parser on your Mac, click Import XML, then choose the export.xml file in the unzipped folder
  2. Check the records that were loaded
  3. Click Export CSV to save the file

The key is that it’s document-based. Import once and save the document in HealthKit Parser’s format, and from then on it opens instantly without parsing the XML again. The first import of a large file takes a while, but after that there’s no waiting.

Your data is never sent anywhere. The app simply reads the file you give it and writes a CSV to the location you choose. It’s a one-time purchase and runs on macOS 12 or later.

→ Learn more about HealthKit Parser

Step 3: Analyze the CSV

The exported CSV is plain text with one record per line. Excel, Numbers, R and Python can all read it directly.

A few tips that make the analysis easier:

  • Filter by the type column: a single file mixes dozens of kinds of data, so narrow it down to the type you need first
  • Check the sourceName column: your iPhone, Apple Watch and third-party apps sometimes record the same metric twice. Be especially careful when adding up steps
  • Dates include a time zone: they look like 2026-09-01 07:12:33 +0900. To aggregate by day, the easy way is to take the first 10 characters
  • Units are in the unit column: the same metric can be recorded in different units depending on the source

Important notes

What you export is your own health record, so take care when sharing or storing it. Also, these numbers are not guaranteed to have the accuracy of a medical device. For decisions about your health, consult a medical professional.