How to Export Your Apple Health Data to JSON and Analyze It with AI
Apple Health holds years of your steps, sleep, heart rate, and workouts — but it's locked behind a clunky XML export that no AI can actually read. Here's how to export Apple Health data to clean JSON and analyze it with an AI agent like Claude, privately and locally.
Your iPhone and Apple Watch quietly record one of the richest datasets you'll ever own: resting heart rate, heart rate variability, sleep stages, VO₂ max, step counts, workouts, body measurements, and well over a hundred other signals. The dream of the quantified-self movement is finally within reach — ask an AI, in plain English, "how has my recovery trended this month?" and get a real answer grounded in your numbers.
The problem is the gap between Apple Health and the AI. Health data is trapped inside HealthKit, and the only built-in way out is an export that's hostile to large language models. This guide walks through the whole pipeline: why the default formats fail, how to get 190 metrics out as clean JSON, how to wire up an open-source MCP server so your agent can query that data on demand, and five prompts to try first.
Why Apple Health's XML and CSV exports fail for LLMs
Open the Health app, tap your profile picture, and choose "Export All Health Data," and iOS hands you a zipped archive containing a single giant export.xml. For an active user with a few years of an Apple Watch, that file is routinely hundreds of megabytes — and it's the wrong shape for an AI in almost every way:
| The problem | Why it breaks AI analysis |
|---|---|
| Massive single file | A 200 MB XML dump is millions of tokens. It blows past every model's context window — you physically cannot paste it into a chat. |
| Every sample, forever | It's raw event logs, not summaries. One day of heart rate alone can be thousands of rows the model has to wade through. |
| Units & metadata scattered | Units, sources, and time zones live in attributes spread across records, so the model misreads or drops them. |
| No semantic structure | Everything is a flat <Record> tag. Nothing groups "sleep this week" or "average HRV" — the AI must reconstruct meaning from scratch. |
| Hand-rolled CSV isn't better | Converting to CSV loses nesting and units too, and you still ship a frozen, stale snapshot the moment you export it. |
Even if you manage to chunk the XML down, the model spends its effort parsing rows instead of reasoning about your health. What an AI actually wants is the opposite: small, clean, per-metric JSON with units, time ranges, and trends already structured — and ideally a live connection so it can ask for exactly the slice it needs.
What Health Export AI does: 190 metrics as clean JSON
Health Export AI is an iOS app that solves the export side of the problem. It reads Apple Health read-only — it can never write to or modify your health data — and turns HealthKit into 190 clean, AI-ready JSON metrics spanning activity, heart, sleep, body, and workouts. Instead of one unreadable archive, you get structured documents an agent can actually consume, with units and time ranges preserved.
Crucially, you choose where that JSON lands, and it's local-first the whole way. There's no account, no sign-in, and nothing routes through a third-party server. The destinations are:
- iCloud Drive — zero setup; the OS syncs the JSON to your Mac or Windows PC automatically.
- A synced folder — Dropbox, Google Drive, OneDrive, Box, Syncthing, or Nextcloud, if you'd rather not use iCloud.
- Your local network — push straight to your computer over HTTP or a live WebSocket (and it reaches a VPS over Tailscale).
- A webhook — an HTTPS POST to any server you run, which is how non-MCP tools like ChatGPT, Gemini, Grok, n8n, or Home Assistant can consume the same data.
That covers the export. The second half — letting an AI query the data conversationally rather than reading a static file — is where the Model Context Protocol comes in.
Installing the open-source health-export-mcp server
The health-export-mcp server is a free, MIT-licensed, zero-dependency MCP (Model Context Protocol) server. MCP is the open standard that lets AI clients call external tools, so instead of pasting a file, your agent gets live tools it can call against your exported Apple Health JSON. It's published to npm and the official MCP registry, and you can read every line of it before you run it.
There are two ways to install it.
Option A — clone and let it auto-configure
The fastest path. Clone the repo and run the installer, which detects your installed clients (Claude Desktop, Cursor, VS Code, opencode, and more) and writes the config for you:
git clone https://github.com/PhilipAD/health-export-mcp.git cd health-export-mcp node apply-mcp-config.mjs # detects your AI clients and wires them up
Want to try it before you even own an iPhone? npm test writes a 14-day sample cache and exercises every tool, so you can see the JSON and the tool calls end-to-end with fake data first.
Option B — add the mcpServers block manually (Claude Desktop)
If you prefer to wire up Claude Desktop by hand, add this to your claude_desktop_config.json. Point HEALTH_DATA_DIR at wherever the app writes (the iCloud path below is the default):
{
"mcpServers": {
"health-export": {
"command": "node",
"args": ["REPLACE_WITH_ABSOLUTE_PATH/server.mjs"],
"env": {
"HEALTH_DATA_DIR": "~/Library/Mobile Documents/iCloud~ai~healthexport~app/Documents"
}
}
}
}
To get the absolute path for the args line, run node -e "console.log(process.cwd()+'/server.mjs')" inside the cloned repo. If you'd rather skip JSON entirely, drag the prebuilt health-export.mcpb bundle into Claude Desktop → Settings → Extensions and you're done. Cursor and VS Code each have a one-click deeplink (run node gen-deeplinks.mjs to print them), and opencode, OpenClaw, and Hermes take the same server block in their own MCP config.
Once it's connected, your agent has seven native tools available: get_mcp_status, list_metrics, get_health_metrics, get_trends, compare_periods, get_structured_export, and query_health_data. You never call these yourself — you just ask questions, and the model decides which to call.
5 example AI prompts for your Apple Health data
With the app exporting and the server connected, here's the part that makes it all worthwhile. Open Claude (or any MCP client) and try prompts like these — each one triggers real tool calls against your live data:
- Recovery check: "What's my HRV trend and recovery this week compared to last week? Am I well-recovered or run down?"
- Sleep coaching: "Summarize my sleep over the last 30 days — average duration, consistency, and which nights were worst. What pattern do you see?"
- Behavior correlation: "Compare my resting heart rate on days I exercised versus days I didn't, over the past two months."
- Weekday vs weekend: "How do my steps and active energy differ on weekdays versus weekends? Give me the numbers."
- Raw export for a deeper dive: "Pull my last 90 days of resting heart rate as structured JSON so we can chart it."
Because the agent queries live data on every call, you never re-export or paste a stale file. Ask a follow-up — "now break that down by week" — and it just calls the tool again.
Privacy: local-first by design
Sending health data to an AI sounds risky, so it's worth being precise about what does and doesn't happen here. Health Export AI is read-only and local-first: it reads HealthKit with your explicit permission, writes JSON only to the destination you choose, and the MCP server runs on your own machine where your agent runs. There are no accounts, no telemetry, and nothing on the developer's servers — your health data never passes through any infrastructure operated by us.
Once data reaches the destination you configure, it's governed by that destination — your cloud provider, your own server, or the AI client you point at it. The open-source server means you can audit exactly what runs locally, and choosing a local folder plus a locally running model keeps the entire pipeline on hardware you control. This is a data-export tool, not a medical device; anything an AI produces from your data is general information, not medical advice.
Get started
The full pipeline is short: install the app, export your 190 metrics to a destination you trust, add the open-source MCP server to your agent, and start asking questions. Most people are querying their own Apple Health data in plain English within a couple of minutes.
Turn your Apple Health into something your AI can read
190 metrics. Clean JSON. Live MCP tools. Local-first and read-only.