Where are iMessages stored on my Mac?
On macOS and iOS, messages are stored locally in an SQLite database located at ~/Library/Messages/chat.db. This database contains your complete message history, including both iMessages and SMS texts, along with metadata about conversations, participants, and attachments.
Database Structure
The chat.db database uses a complex relational schema with numerous interconnected tables. Key tables include:
- message: Contains message text, timestamps, sender/recipient information, and read status
- chat: Represents conversations, both individual and group
- handle: Stores contact identifiers like phone numbers and email addresses
- attachment: Metadata for photos, videos, audio files, and documents
- chat_message_join: Links messages to conversations (many-to-many relationship)
- message_attachment_join: Links messages to attachments
- chat_handle_join: Links conversations to participants
Message Text Storage
Recent macOS versions (Ventura and later) store message text as hex-encoded blobs in the attributedBody column rather than plaintext. This encoding preserves formatting information like bold, italic, and links, but adds complexity to direct database access. Tools like TextKeep automatically handle this encoding when exporting messages.
Attachment Storage
Large media files are stored separately in the file system, with the attachment table containing file paths pointing to their locations. When storage fills, iOS and macOS may offload older attachments to iCloud, leaving only metadata and low-resolution previews locally. This creates challenges for export—tools may encounter "Attachment stored in iCloud" placeholders instead of actual files.
Accessing the Database
The chat.db file is protected by macOS security permissions. Applications need "Full Disk Access" permission to read the Messages folder. TextKeep requests this permission when you first run it, allowing the app to safely read and export your message history without modifying the original database.
Download TextKeep for Mac