Where Are Text Messages Stored on iPhone?
In this article
Text messages on an iPhone are stored in a single SQLite database file called sms.db, located inside the Messages app's data container at /var/mobile/Library/SMS/sms.db. You cannot browse this file directly on the iPhone without jailbreaking, but you can access it through an encrypted local backup on a computer. This guide explains where the data lives, how to locate it using an official backup, and what to do if you need to view or recover messages.
What You'll Need
- A computer running macOS (Catalina or later) with Finder, or Windows/macOS with iTunes installed.
- A Lightning or USB-C cable to connect your iPhone.
- The passcode for your iPhone (to trust the computer).
- Optional: a third-party SQLite browser (e.g., DB Browser for SQLite) if you want to inspect the database file.
Step-by-Step
- Back up your iPhone to your computer. Connect your iPhone to the computer and open Finder (macOS Catalina or later) or iTunes (Windows or older macOS). Select your device when it appears. In the Summary or General tab, choose “Back Up Now” under the “Back Up Your iPhone” section. Make sure “Encrypt local backup” is checked and set a password you will remember. An encrypted backup includes the Messages database; an unencrypted backup does not include the sms.db file in a readable form.
- Wait for the backup to complete. The time depends on your data size. Keep the iPhone connected until the progress bar finishes and the “Backup” button becomes clickable again.
- Locate the backup folder on your computer. The backup is stored in a hidden folder. On macOS, open Finder, press Cmd+Shift+G , and go to ~/Library/Application Support/MobileSync/Backup/ . On Windows, open File Explorer and navigate to . You may need to show hidden files to see the AppData folder.
- Find the folder for your iPhone. Inside the Backup folder, you will see one or more subfolders with long hexadecimal names (e.g.,
a1b2c3d4...). Each corresponds to a device backup. To identify the right one, check theInfo.plistfile inside each folder using a plist editor, or simply sort by date modified to find the most recent backup. - Locate the sms.db file. Inside the correct backup folder, open the
3d0d7e5fb2ce288813306e4d4636395e047a3d28file (this is the hashed name for the SMS database). You can rename a copy tosms.dbfor easier opening. This file contains all your text messages, including iMessage and SMS, along with timestamps and contact information. - Open the database with an SQLite viewer (optional). Use a tool like DB Browser for SQLite to open the file. The
messagetable holds the actual message text, while thehandletable links to phone numbers or email addresses. You can browse or export the data. Note that the database may be encrypted if you used an encrypted backup; in that case, you will need your backup password to decrypt it with third-party software.
Common Mistakes
- Looking for sms.db directly on the iPhone. Without jailbreaking, you cannot access the file system. The only official way to extract the database is through an encrypted backup.
- Using an unencrypted backup. Unencrypted backups do not include the sms.db file in a usable form; the Messages data is omitted or stored differently. Always enable encryption.
- Confusing iMessage and SMS storage. Both are stored in the same sms.db file, but iMessage attachments (images, videos) are stored separately in the
Attachmentsfolder within the same directory. - Deleting the backup folder prematurely. Once you delete a backup, the sms.db file is gone. Keep a copy before experimenting.
- Expecting to see messages in iCloud. If Messages in iCloud is enabled, the local database may be smaller or synced differently, but the backup still contains the full history if encryption is on.
Tips
- Always encrypt your local backup. It not only includes the Messages database but also saves your passwords and health data.
- If you only need to read messages, you can use third-party backup extractor tools that handle the decryption and present the data in a readable format. Ensure you download from the official developer site.
- Regular backups protect your message history. Set up automatic backups via iCloud or manually back up to your computer periodically.
- For forensic or legal purposes, consider using specialized software that preserves the database integrity, but always follow local laws and privacy regulations.
Troubleshooting
- Backup fails or hangs. Restart both iPhone and computer, ensure enough free space on the computer, and try a different USB port or cable. If the backup still fails, update iTunes/Finder and iOS to the latest versions.
- Cannot find the Backup folder. On macOS, the Library folder is hidden by default. Use the Go to Folder shortcut. On Windows, enable “Show hidden files” in File Explorer options.
- sms.db file is missing from backup. Check that the backup was encrypted. If it was, the file should be present. If not, redo the backup with encryption enabled.
- Database is locked or unreadable. Close any app that might be using the file. Copy the file to a different location before opening. If it is encrypted, use the backup password to decrypt it with a tool like iBackup Viewer or similar.
- Messages appear incomplete. If Messages in iCloud is enabled, some messages may not be included in the local backup if they haven't been downloaded to the device. Ensure all messages are downloaded by opening the Messages app and scrolling through conversations.
Frequently Asked Questions
Can I view sms.db directly on my iPhone?
No, iOS does not provide file system access to users. You need to create an encrypted backup and extract the file on a computer.
Where are iMessage attachments stored?
Attachments are stored in the Attachments subfolder within the same SMS directory, both on the device and in the backup. They are not inside sms.db itself.
Does iCloud backup include sms.db?
Yes, iCloud backups include the Messages database, but you cannot directly access the file from iCloud. You would need to restore the backup to a device or use third-party software to extract it from an iCloud backup.
What if I forgot my backup password?
Without the password, the encrypted backup cannot be decrypted, and the sms.db file remains inaccessible. There is no official way to recover or bypass the password.
Are text messages stored on the SIM card?
No, modern iPhones store SMS and iMessage data in the device's internal storage, not on the SIM card. The SIM card only holds carrier-related information.
Can I transfer sms.db to a new iPhone?
You cannot manually copy sms.db to a new iPhone. Use iCloud backup, encrypted local backup, or Quick Start to transfer messages during setup.