I needed a script to read my work WhatsApp every few minutes and list the messages still waiting on a reply. WhatsApp has no API for reading your personal account, so I went looking at what the Mac app stores. All of it is on disk in ordinary SQLite files, and the message text is unencrypted.
I looked at WhatsApp for Mac 26.48.12 on macOS 15, in November 2026. The counts are from my work account, and I left out what any message says. An update can change all of this.
WhatsApp for Mac is a Mac Catalyst app
The Mac binary is built for Mac Catalyst, Apple’s way of running an iPad or iPhone app on macOS. otool shows the platform in the binary’s build version, and the app’s Info.plist declares the Mac user-interface idiom:
$ otool -l /Applications/WhatsApp.app/Contents/MacOS/WhatsApp | grep -A3 LC_BUILD_VERSION
cmd LC_BUILD_VERSION
cmdsize 32
platform 6 # PLATFORM_MACCATALYST
minos 15.2
$ defaults read /Applications/WhatsApp.app/Contents/Info.plist UIDeviceFamily
( 6 )So the Mac app uses the iPhone app’s database. Forensic tools that parse iPhone backups, such as iLEAPP, already know its tables. On a Mac the file sits in your home folder, where any process you run with access to it can read it.
The group container
The data lives in an App Group container that the main app and its extensions share:
~/Library/Group Containers/group.net.whatsapp.WhatsApp.shared/These are the files I looked at, with their sizes on my Mac.
| Path | Size | What it holds |
|---|---|---|
ChatStorage.sqlite | 11 MB | chats, messages, attachments, group members |
ContactsV2.sqlite | 0.2 MB | the address book as WhatsApp sees it |
LID.sqlite | 0.1 MB | a map from anonymous member ids to phone numbers |
Axolotl.sqlite | 1.3 MB | the Signal protocol state: sessions, prekeys, sender keys |
CallHistory.sqlite | 0.1 MB | calls |
Message/Media/ | 1.3 GB | downloaded photos, videos, voice notes and documents |
fts/ | 3 MB | a full-text search index |
Logs/ | 30 MB | the app’s logs |
Each database has -wal and -shm files next to it, because they run in SQLite’s WAL mode.
A Core Data store
ChatStorage.sqlite is a Core Data store. Core Data names each table after its entity with a Z prefix, gives every column a Z prefix, and adds three bookkeeping columns to every table: Z_PK (the row id), Z_ENT (which entity the row belongs to) and Z_OPT (a version number Core Data uses for optimistic locking).
Z_PRIMARYKEY lists the entities, with Z_MAX, the highest id handed out so far:
sqlite> select Z_ENT, Z_NAME, Z_MAX from Z_PRIMARYKEY;
4|WAChatSession|149
5|WAGroupInfo|18
6|WAGroupMember|1086
8|WAMediaItem|9656
9|WAMessage|9873
11|WAMessageInfo|7733
12|WAProfilePictureItem|999
...My script reads four of these tables.
| Table | A row is | Columns I use |
|---|---|---|
ZWACHATSESSION | a chat | ZPARTNERNAME, ZCONTACTJID, ZLASTMESSAGEDATE, ZUNREADCOUNT |
ZWAMESSAGE | a message | ZCHATSESSION, ZMESSAGEDATE, ZISFROMME, ZMESSAGETYPE, ZTEXT, ZGROUPMEMBER, ZSTANZAID |
ZWAGROUPMEMBER | a person in a group | ZMEMBERJID, ZCONTACTNAME |
ZWAMEDIAITEM | whatever is attached to a message | ZMESSAGE, ZMEDIALOCALPATH, ZMEDIAURL, ZMETADATA |
ZSTANZAID is the message id WhatsApp uses on the wire. In my copy these ids come in three lengths: 20, 22 and 32 characters.
Dates count from 2001
ZMESSAGEDATE is a float of seconds since 1 January 2001 UTC, the reference date of Apple’s NSDate. Add 978,307,200 to get a Unix timestamp. The newest message in my copy:
sqlite> select ZMESSAGEDATE, datetime(ZMESSAGEDATE + 978307200, 'unixepoch')
...> from ZWAMESSAGE order by ZMESSAGEDATE desc limit 1;
817628615|2026-11-29 07:03:35Message types
ZMESSAGETYPE is an integer, and the database has no table that names the values. My copy has 26 distinct values. I worked out what a type means from what else its rows carry: text, the MIME type of an attachment, a duration, coordinates, or a vCard.
| Type | Rows | What its rows carry |
|---|---|---|
| 0 | 7,683 | text: every row has ZTEXT |
| 1 | 860 | image: MIME image/jpeg |
| 2 | 106 | video: video/mp4 with a duration of 2 to 252 seconds |
| 3 | 16 | voice note: audio/ogg; codecs=opus or audio/mp4, with a duration |
| 4 | 77 | contact card: BEGIN:VCARD text on every row |
| 5 | 1 | location: real coordinates |
| 6 | 63 | a system notice in the chat, with a code in ZGROUPEVENTTYPE |
| 7 | 70 | link: text, and a URL in ZMEDIAURL |
| 8 | 467 | document: PDF, Word, Excel, zip |
| 11 | 8 | GIF, stored as video/mp4 |
| 15 | 88 | sticker: image/webp |
I can’t name the other 15 types with confidence. They include 187 rows of type 10 and 50 of type 14. My extractor keeps those as numbers.
Reused columns
Four ZWAMEDIAITEM columns hold data unrelated to their names when the attachment is an image or a document. I checked each one against the files on disk.
| Column | Name suggests | Holds for images and documents |
|---|---|---|
ZVCARDSTRING | a contact card | the MIME type, e.g. application/pdf |
ZLATITUDE | a coordinate | the image height in pixels |
ZLONGITUDE | a coordinate | the image width in pixels |
ZMOVIEDURATION | a video length | the page count of a PDF |
For the eight most recent images, ZLATITUDE and ZLONGITUDE matched the height and width sips reported for the file. For six PDFs, ZMOVIEDURATION matched the page count Spotlight reported, from 1 page to 83. A location message uses the same two columns for real coordinates, so a script has to check the message type before it reads them.
Attachments
ZMEDIALOCALPATH is relative to the Message/ folder and looks like Media/<chat id>/3/3/<uuid>.jpg, with two levels of single-character folders under each chat. Only 840 of the 1,449 photos, videos, voice notes and documents in my copy have a local file. The rest were never downloaded to this Mac.
For those, ZMEDIAURL points at an encrypted blob on mmg.whatsapp.net, and ZMEDIAKEY holds the key to decrypt it, wrapped in a protobuf (76 or 112 bytes in my copy). For a link message the same ZMEDIAURL column holds the link. I haven’t decrypted any blobs, because the local files were enough for what I needed.
The protobuf in ZMETADATA
The 7,683 text messages have no attachment, but 7,674 of them have a ZWAMEDIAITEM row anyway. Those rows are empty apart from ZMETADATA, a protobuf blob. protoc --decode_raw decodes them without a schema. I ran it over a random sample of 300 and recorded only which field numbers appear, never their contents.
Field 68 is in all 300. About 28% also carry fields 5, 6 and 19 together, and those are replies. I checked a second random sample of 250: 59 had field 5, and for all 59 its value was the ZSTANZAID of another message in the database, while field 6 was a WhatsApp user id (a JID). Field 19 is a nested message with a copy of the quoted message’s content. Each reply stores its own copy of the text it quotes.
Sender names
WhatsApp identifies people and groups by JID: <phone>@s.whatsapp.net for a person, <id>@g.us for a group. Newer rows in ZWAGROUPMEMBER often hold an id ending in @lid in place of a phone number. To get a name for a group message, a script has to join across three files:
ZWAMESSAGE.ZGROUPMEMBERpoints at a row inZWAGROUPMEMBER, which gives aZMEMBERJID, possibly a@lid.LID.sqlitemaps@lidids back to phone numbers. The table whose name suggests this,ZWAPHONENUMBERLIDPAIR, was empty in one backup I have, andZWAZACCOUNTheld the same pairs, so my script reads both.ContactsV2.sqlite, tableZWAADDRESSBOOKCONTACT, givesZFULLNAMEby lid or by WhatsApp id.
Before I added those joins, some group senders came out as strings like +IAE=. The app had stored a base64 value where a display name would go, and only the address book had the real name.
Axolotl.sqlite
Axolotl.sqlite holds the account’s end-to-end encryption state. Axolotl was the original name of the Signal protocol’s ratchet. The file’s tables include ZWAAXOLOTLSESSION, ZWAPREKEY (1,733 rows), ZWASIGNEDPREKEY and ZWASENDERKEY for groups. There is also a ZWAPOSTQUANTUMPREKEY table, empty in my copy. I only listed the table names and row counts. The file holds the account’s encryption keys, so my scripts never read or copy it.
Copying the database before reading it
Opening ChatStorage.sqlite in place while WhatsApp writes to it risks lock contention, and recent writes may still be in the -wal file. My script copies the database with its -wal and -shm files to a separate folder, opens the copy with mode=ro, and joins the tables into one row per message:
import os, shutil, sqlite3, datetime
SRC = os.path.expanduser("~/Library/Group Containers/group.net.whatsapp.WhatsApp.shared")
DST = "wa-copy"
os.makedirs(DST, exist_ok=True)
for f in os.listdir(SRC):
if f.startswith("ChatStorage.sqlite"): # the db and its -wal and -shm
shutil.copy2(os.path.join(SRC, f), DST)
con = sqlite3.connect(f"file:{DST}/ChatStorage.sqlite?mode=ro", uri=True)
rows = con.execute("""
select c.ZPARTNERNAME, m.ZMESSAGEDATE + 978307200, m.ZISFROMME, m.ZMESSAGETYPE, m.ZTEXT
from ZWAMESSAGE m join ZWACHATSESSION c on c.Z_PK = m.ZCHATSESSION
order by m.ZMESSAGEDATE desc limit 20""")
for chat, ts, mine, mtype, text in rows:
when = datetime.datetime.fromtimestamp(ts) if ts else None
print(when, chat, "me" if mine else "them", mtype, (text or "")[:60])Copying three files while the app writes could catch them at slightly different moments. The script has run every 15 minutes since 12 November without a problem I could see, but SQLite’s backup API on the live file would rule it out.
A logout deletes the local history
On 10 November a work account I had access to was logged out of the Mac app, and the app deleted its local history. The copy my script had made earlier was the only complete record left: 106,625 messages across 776 chats. None of the media survived, because I had copied only the databases.
To a script, a logout looks like an ordinary run that found fewer messages, and the next run would have overwritten the only copy with a nearly empty one. The script now refuses to copy a ChatStorage.sqlite that is missing or less than half the size of its last copy. The scheduled job that runs it restores the previous output and reports an error if the message count falls by more than 20% between runs.