I’ve been wanting a searchable archive of all my messages. My goals were finding old conversations that reflect my situation at the time (useful when making my morning notes), for Quantified Self analysis, and for supplying background knowledge for AI supported inquiry of various kinds. Here’s what I did.
Click to expand
Apple stores messages in ~/Library/Messages/chat.db, a SQLite database. However, they’ve made it intentionally difficult to access:
- Permission barriers - The database requires Full Disk Access permissions, which most apps (including Terminal) don’t have by default.
- Non-standard timestamps - Apple uses nanoseconds since 2001-01-01 instead of Unix timestamps.
- Complex schema - Messages are spread across 17+ tables with multiple joins required to reconstruct conversations.
- No export option - Messages.app has no built-in export functionality.
I appreciate Apple’s “privacy by default” approach but sometimes there also seems to be a “our private property by default” aspect to the data structures: technically accessible but practically locked in.
At first I worked with Claude Code to parse the SQLite database directly, but I ran into problems getting the complete dataset. Since I have over 40 GB of messages, I don’t have them all locally, and after a few hours of trying I still wasn’t sure how to copy the full database. Somebody more skilled than I am might be able to figure out it, but from Reddit, Apple Community comments, and Stack Overflow, I gathered that it was generally considered impossible. There were many recommendations of iMazing, a third-party iOS/macOS management tool. I hate paying for 3rd party export tools; it seems unjust that this is necessary, and in the past I’ve had some bad experiences with tools that promised data export but didn’t really deliver. But this was my only way forward, so I went for it.
The free version of iMazing is limited to a few conversations, but this was enough to at least run some tests. They worked, so I bought a one-year license for $50. The export process was straightforward:
- Connect your device or select your Mac’s messages
- Choose “Messages” from the sidebar
- Select conversations (or all)
- Export to CSV format
The resulting CSV included 156,000+ lines with the metadata I wanted: delivery timestamps, read receipts, sender names, reply threading, and attachment info.
From here, I worked with Claude to create a simple Python script that converts the CSV to readable Markdown, for human eyes, and some scripts for querying the tabular data. The process was iterative:
- Started with a test file (first 1,000 lines) to verify the format
- Built a basic parser to group messages by date and conversation
- Added progress tracking for the full 156K line file
- Generated a 12MB Markdown file with all 124,000+ messages
The script handles the CSV parsing, date formatting, and Markdown escaping in about 30 seconds. There were few problems with the Markdown, since my text messages include a few code snippets, but these were easy to spot and hand edit.
NOTE: Claude required careful supervision to limit the scope. I stayed in planning mode for quite a few rounds as Claude continued to elaborate complex ideas despite my having set what I thought were clear guardrails. With a level of nitpicky correction, my robot assistant finally conformed.
I now have a complete, searchable archive of every text I’ve sent or received. It’s grouped by date with conversations as subheadings, making it easy to see what I was discussing on any given day.
The total cost was $50 and two hours work. Most of this work was going down dead ends to avoid paying for iMazing, so you can skip this part of you want to end up where I did. Feel free to ask any questions here if you want to try it.
Note July 31, 2025:
This is working even better than I hoped. I ask Claude questions like: “what was I doing on August 1, 2022” and I get answers like:
On August 1st, 2022, you were traveling in France with Christa - you spent the day swimming in Nice and helped Christa with her hair while someone named Ludo warned you about hot weather inland."*
The activities recorded in the sms archive trigger intense memories, and their seeming insignificance is part of what makes them real. The details are often slightly wrong, and I can usually detect these mistakes, but instead of ruining the effect it strengthens it. There’s a slight friction, like when you are talking about old times but something is out of order, and it sends my mind back to solve it. I sometimes check the sms record directly if I’m unsure. Names of people I haven’t thought about in a while are especially affecting.