Recently, I did a full restore on my iPhone to try and fix some of the many problems I’ve been having (we’ll save that list for another day). While SMS messages are generally temporary in nature, I decided to find out if I could export them somehow. There are a few programs out there that claim to be able to do this for you, such as MobileSyncBrowser (Mac/PC, free trial/$10/$20), iPhone / iPod Touch Backup Extractor (Mac, free), or an online tool like iphone backup sms extractor. I didn’t try any of these because I don’t want to pay, I am not on a Mac, and I don’t want to upload my private messages to some random site. Luckily, I discovered that it’s not too hard to do it yourself. Grab your iPhone, put on your techie hat, and follow the 3 easy steps after the break!
Step 0 – Before You Start:
A couple things you need to take care of before diving in to the tutorial:
- Make sure to do a sync/backup of your iPhone in iTunes before starting to ensure all messages will be extracted.
- Download SQLite Database Browser as you will need this to browse/export the database once finding it.
Step 1 – Find the Backup File:
The SMS messages are stored in an SQLite database file that is located in a backup folder somewhere on your computer. The file is (most likely) named
3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata
On Windows, the path to the folder should resemble something like the following:
C:\Documents and Settings\[username]\Application Data\Apple Computer\MobileSync\Backup\[some random id]\
On a Mac, you should find it at:
home/Library/MobileSync/backup/[some random id]/
Or just search your computer for 3d0d7e5fb2ce288813306e4d4636395e047a3d28.
Once you find the file, you can verify that it is an SQLite database by opening it in a text editor and making sure the first characters of the file are “SQLite format 3″.
Just to be safe and, copy the file to your desktop or another folder and rename it something shorter like sms.sqlite.
Step 2 – Browsing the SMS SQLite Database
You will need the SQLite Database Browser as mentioned above, so go download it now if you haven’t already!
Once you have it downloaded, extract the program and run it! Click File > Open and navigate to where you saved the copy of the backup file. When you open this file you will see an interface that should be familiar if you’ve ever used any sort of database management tool.
From the Table drop-down menu, choose the message table. This is the main table we’re interested in and you don’t really need to use the other tables at all but go ahead and take a look if you’re interested!
There are a few fields that we are interested in:
- address: This holds the phone number of the person that sent you or you sent the message to.
- date: This is a Unix timestamp of when the message was sent.
- text: The actual message.
- flags: This should be either 2 or 3. The messages flagged 3 are messages that you sent (outgoing), while the messages flagged 2 are incoming messages.
Step 3 – Exporting:
Still using SQLite Database Browser program, click File > Export > Table as CSV File. Choose the messages table and click Export. Choose a filename like sms.csv, hit Save, and you’re done!
Now you can open the CSV using Excel (or equivalent) and laugh/cry/look at all the funny/angry/crazy messages you have sent and received over the years/weeks/days!
To convert the datestamp to a human readable format in Excel, use the following formula (from SpreadsheetPage.com):
=(((A1/60)/60)/24)+DATE(1970,1,1)+(-5/24)
where A1 is the cell holding the datestamp, and -5 is your timezone GMT offset.
You can also duplicate (copy/paste) the address column and then do a find and replace of the phone number with the person’s actual name (useful at least for the people you text the most with).
Notes:
This will not export emoticons/emoji/MMS messages. There may be a way to grab these (table msg_pieces may give some hints), but I’m not really worried about losing this info.
You will only get the phone numbers of the messages, not the names (though it’s easy enough to do a find and replace for your most used phone numbers).
That’s it! I hope this will be useful to someone, and if you have any questions or comments, or find any errors in this post just leave a comment!








Hello, and thanks for presenting this tip! Unfortunately, it did not work for me… SQLite Database Browser shows error message “File is not SQLite 3 Database”. Am I doing something wrong???
Hey,
A couple things to check:
– Are you sure the file you are using is “3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata”? Make sure your file has the .mddata file extension as there is another file with the same name but different extension. Check closely to make sure you have the correct file, and this will probably solve your problem!
– Second, in iTunes, do you have the “Encrypt my iPhone backup..” option checked? If so, you won't be able to access your SMS messages as described in the post. You could uncheck this option, backup your phone again, and then you should have an unencrypted version.
Hope this helps! Let me know how it goes…
Matt
Thanks for your help on this. Question: The date column in my .csv file lists a string of numbers instead of dates — is there a way to convert these? Thanks.
Hey,
Check Step 3 of the tutorial for a way to convert the timestamps into a more readable format (using Excel):
“To convert the datestamp to a human readable format in Excel, use the following formula:
=(((A1/60)/60)/24)+DATE(1970,1,1)+(-5/24)
where A1 is the cell holding the datestamp, and -5 is your timezone GMT offset.”
Hope that helps.
Matt
Everything works perfectly, except when i open my excel document, all the information appears in the first column… what am i doing wrong?
I am having the same issue as C. Royal ;( Did you find a fix? I really appreciate any advice!
Hello!
This works very well, except that all the data gets sorted into a single column, with commas and speechmarksk as the separators of the data per SMS. Am i doing something wrong? The .csv file appears to just work as a text file without tabular format.
Thank you!
-Pekka
You may have to use Excel's “Text to Columns” feature. Try that and
let me know if it helps!
If you're still having problems, you could send me a few lines of your
csv file. Just make sure you don't include any texts with private info!
This works great, got all the info. The one problem I'm having is the date conversion. It doesn't seem to be working. It coverts the date field, but not into a human readable date. Any help appreciated!
Thanks so much for posting this!
Nevermind! I had to covert the row to a date field and it worked great! Thanks so much! You rock!
[...] This post was mentioned on Twitter by thecoolside. thecoolside said: Want to archive your iPhone texts? Free up memory but save "important" conversations. http://bit.ly/cstnUu #notforfaceboxers [...]
Great! Glad you got it working.
Is it possible to then reimport messages on a freshly restored iPhone? I'm looking to do a full restore but would like to backup SMS only.
I'm not sure if this is possible, and unfortunately can't test it at the moment.
Though I would guess that this may be possible:
– Save the 3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata and 3d0d7e5fb2ce288813306e4d4636395e047a3d28.mdinfo files from your phone before restoring.
– Restore the phone, and backup at least once (so that the new backup folder will be created).
– Next, copy the above two files into the new backup directory and then do a “Restore from Backup…”; you should be left with a restored phone but with your old SMS messages.
If you do try this out and it works, let me know! Make a copy of your original backup just in case something goes wrong.
Matt
Thanks! Should be able to try out that over the weekend, I'll keep you posted
Unfortunately the backup process in iOS 4 has been changed so I can't simply replace the files.
I'll check more thoroughly in a few days…
Just got the iPhone4. I want to keep the old texts but essentially start anew with everything else (since I was jailbroken before). If you figure it out please post here! I am very interested.
when Itey to open the file its saying that that an error has occurred: file is not a sqlite 3 database
when I try to open……(sorry)
Donut here, Hi matthew
backed up, downloaded sqlite, and can't find the file 3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata or anything resembling this.
got some important texts i need to save, i am jailbroken but not housebroken
Regards, Donut
Did you try doing a file search on your computer?
Also, are you using “encrypted backups” (you can check to see if you have this checked in iTunes)? If so, you will need to turn off encrypted backups and do a non-encrypted backup to be able to extract your texts using this method.
Yes done a file search already, encrypts in itunes was already turned off.
Whilst waiting for you very swift reply, i went the open ssh way, and winscp. I'm in, but no idea what to do next as im a noob. I just wanna get these messages copied and viewable in some way. Cheers
Are you on a Mac? If so, this program should work:
http://supercrazyawesome.com/