Where apps hide your files
Your iMessage and SMS history on a Mac lives in one database file, chat.db, in a protected folder inside Library. Here is where it is, how Messages in iCloud fits in, and the safe ways to keep a copy.
~/Library/Messages/chat.db
That is the Messages database on recent macOS releases: your iMessage and SMS history, with the text of each message, who it was with and when. Two companion files sit beside it, chat.db-wal and chat.db-shm, which SQLite uses for changes not yet merged into the main file. On the Mac used for this guide the folder looks like this (sizes and names only, nothing was read):
| Item | Size or role |
|---|---|
chat.db | 331 KB |
chat.db-wal, chat.db-shm | 32 KB each |
Drafts | Unsent drafts |
NickNameCache | Cached shared names and photos |
CollaborationNoticeCache | Cache for shared-file notices |
Sync | sync.db, used for syncing |
LiteSegmentStore.db | A small store used by the app |
Apple does not document these files, so the table describes one Mac, not a specification.
The usual home for photos, videos and files people sent you is:
~/Library/Messages/Attachments
On the Mac used for this guide that folder does not exist, so expect it to be missing on a Mac that holds no attachments locally. Third-party guides and developer write-ups describe it as the standard location. Individual files sit in numbered and hashed subfolders and keep their original names, rarely the sender's name. A separate post covers finding them.
The folder is inside the hidden Library, and macOS protects ~/Library/Messages. In Finder press ⇧⌘G, type ~/Library/Messages and press Return. In Terminal:
open ~/Library/Messages
If a Terminal command such as ls ~/Library/Messages says "Operation not permitted", Terminal needs Full Disk Access. Open System Settings > Privacy & Security > Full Disk Access, switch Terminal on, then quit and reopen it. Full Disk Access is broad, so grant it only to apps you trust and consider turning it off again afterwards.
If you use Messages in iCloud, your history lives in iCloud and each device keeps a local copy, so chat.db is that copy. Apple's steps on a Mac are: open Messages, choose Messages > Settings, click iMessage, and select Enable Messages in iCloud. Apple says the Mac then updates automatically, and Sync Now in the same pane pulls texts from your other Apple devices, for example after you switch to a new Mac. It may take a while for everything to appear. When you turn it off, Messages offers to do so for just this Mac or for all your devices, and says your Messages data is downloaded to the device and stops syncing to iCloud.
Apple's Messages guide is explicit:
Check Keep messages first if old history seems to vanish on its own.
The supported choice is Messages in iCloud, plus an ordinary backup. Time Machine includes ~/Library, so chat.db and Attachments are in your backups unless you excluded them.
If you want a separate copy of the Mac's files:
chat.db, chat.db-wal and chat.db-shm together, and the Attachments folder if present, to an external drive in Finder.chat.db back, never do it while Messages is running, and with Messages in iCloud on an older database can conflict with what iCloud holds once Messages syncs again.A copy of chat.db is a database, not a readable archive. Double-clicking it will not show conversations, and nobody should open it in an editor or edit it. Tools that read it work on a copy and need Full Disk Access, which is broader than Messages access. Apple's Messages guide does not describe a one-click export of full history.
Two routes are dependable. If you use Messages in iCloud, turn it on for the new Mac under Messages > Settings > iMessage and wait for it to download, using Sync Now if it stalls. Otherwise, use Migration Assistant or a Time Machine restore when setting up the new Mac, which brings your Library across. Copying chat.db into a Mac you are already running Messages on is not a route Apple documents, and with Messages open it can conflict with the live database.
Attachments are usually the part that grows. Apple's way to clear them in bulk: select a conversation, click the Info button in the top-right corner, scroll to a category such as Photos, click Show more, Shift-click the items, Control-click them and choose Delete. They then sit in Recently Deleted for up to 30 days unless you remove them there. Removing files from Attachments by hand leaves conversations showing missing media. Use du -sh ~/Library/Messages/* (read only) to see which part is large.
chat.db, its -wal or -shm file, or the Sync folder: the database is your local history, and Apple does not document how Messages rebuilds any of them.~/Library/Messages is protected by macOS and hidden inside Library, so Spotlight and Finder searches leave it out. Messages stores its text inside one database, so searching Finder for a phrase from a chat finds nothing in that folder. Messages' own search field searches message text.
Type chat.db into Everywhere to find the database and its -wal and -shm companions, or type a photo's file name to find a saved attachment inside Attachments. ~/Library/Messages is a protected folder, so Everywhere finds these once it has Full Disk Access. It matches names only and never reads your messages, and ⌘↵ reveals the file in Finder.
At ~/Library/Messages/chat.db, with chat.db-wal and chat.db-shm beside it. macOS protects that folder, so Terminal needs Full Disk Access to list it.
Usually in ~/Library/Messages/Attachments. On some Macs that folder does not exist until attachments are stored locally, so check the folder rather than assume it.
Both, if Messages in iCloud is on: the history lives in iCloud and the Mac keeps a local copy. Turn it on under Messages > Settings > iMessage > Enable Messages in iCloud.
Time Machine includes the Library folder, and Messages in iCloud keeps another copy. For a manual copy, quit Messages and copy chat.db with its -wal and -shm files and the Attachments folder.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised