How do I get my Apple Health data into a CSV file or a spreadsheet?
Run healthsql query --csv "SELECT * FROM daily" > daily.csv on your Mac: you get one row per day with Apple Health's own daily totals (steps, energy, heart rate, HRV, sleep, weight and more), ready for Excel, Numbers or Google Sheets. HealthSQL is not a CSV export app with schedules and destinations; it is one command that turns any SQL query on your Health record into CSV.
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. Setup: install the iPhone app and the command.
Examples
Every day, every column of daily:
healthsql query --csv "SELECT * FROM daily ORDER BY day" > daily.csvYour workouts:
healthsql query --csv "SELECT day, activity, minutes, meters, avg_hr, max_hr, kcal, source_name FROM workouts ORDER BY start_ts" > workouts.csvWeekly averages for this year:
healthsql query --csv "SELECT strftime('%Y-%W', day) AS week, round(avg(steps)) AS steps, round(avg(resting_hr), 1) AS resting_hr, round(avg(asleep_min)) AS asleep_min FROM daily WHERE day >= date('now', 'start of year') GROUP BY week" > weeks.csvEach night's sleep:
healthsql query --csv "SELECT * FROM nights ORDER BY night" > sleep.csvThe first line of the file is the column names. Steps and flights are whole numbers; energy is kcal, distance meters, weight kg, and a percent such as spo2 is a 0-1 fraction. Every column: schema reference.
What to know
- At most 2000 rows. A query returns at most 2000 rows; when it is cut, the command says so on the terminal, not in the file.
dailyhas one row per day, so 2000 rows is about five and a half years. For more, add aWHEREon the date, or read the database file directly (below). - Warnings stay out of the file. If the phone has not synced lately, or you share only part of your history with the app, the command prints that on the terminal and keeps the CSV clean.
- Fresh as the last export. Each command first reads any new files from the iPhone.
More than 2000 rows
The database is a plain SQLite file. Run healthsql sync first so it holds the latest files, then use sqlite3 with no row limit:
sqlite3 -readonly -header -csv "$HOME/Library/Application Support/HealthSQL/health.db" "SELECT * FROM daily ORDER BY day" > daily.csvIf you want scheduled CSV files
HealthSQL has no schedules or destinations. If you want CSV files written on a schedule to Google Drive or Dropbox, or sent to a server, an export app such as Health Auto Export does that (how they compare, other export apps). An agent can also run the command on a schedule for you.
Questions
Can I open the CSV in Google Sheets?
Yes. Google Sheets, Excel and Numbers all open CSV files.
Why are my step counts lower than another export's?
daily holds Apple Health's own total, which counts steps once when a Watch, a phone and a ring all recorded them. A plain sum of raw samples counts them two or three times. Why.
Can I get raw samples as CSV?
Yes, for one metric at a time: healthsql query --csv "SELECT start_local, value, unit, source_name FROM samples WHERE metric = 'HeartRate' AND day = '2026-11-29'" > hr.csv. Raw samples run to millions of rows, so always filter.