DEV Community

Philip D'Souza
Philip D'Souza

Posted on

Apple Health data for AI: why clean JSON beats CSV and XML

Apple Health exports as a single zipped export.xml, and that one file is where a lot of AI health analysis quietly goes wrong. It mixes every record type together, repeats verbose HealthKit attribute names on every reading, and can run to hundreds of megabytes. It is the format HealthKit chose, not the one a language model reads well.

The usual fix is to convert it. CSV is compact and imports anywhere, but it is flat and header-dependent: the value means something only while the header row is attached, and that breaks the moment rows are pasted or windowed in a conversation. XML has all the structure but pays for it in verbosity and an unfamiliar schema.

Clean JSON is the sweet spot. Keys are inline labels, units travel with values, and nesting lets a scalar, a pair and a series sit in one payload. The next step is to stop shipping files at all and let the agent query the exact metrics it needs over MCP, so it gets a small typed object instead of your whole history.

Full comparison, with the same HRV reading in all three formats, the five-dimension table, and how health-export-mcp turns 190 HealthKit metrics into queryable JSON: https://www.healthexport.dev/blog/apple-health-json-vs-csv-xml-for-ai?utm_source=devto&utm_medium=social&utm_campaign=exp-20261007-hea190-jsoncsvxml

Top comments (0)