How to export SMS conversations from your iPhone into text

You probably know this. There are some very precious SMS conversations on your iPhone, maybe with that special someone, and you want to archive them. You know that they are backed up regularly by iTunes, but what if you want to view them on your desktop machine? Or send them to that special someone? If you don’t have your iPhone backups encrypted and know your way about sqlite it’s actually very easy.

sqlite3 "/Users/dirk/Library/Application Support/MobileSync/Backup/<UDID>/3d0d7e5fb2ce288813306e4d4636395e047a3d28"
.mode list
.separator ' '
.output <absolutefilename.txt>
select strftime('%Y-%m-%d %H:%M',date,'unixepoch'),case when flags=3
 then '<yourname>:' else '<othername>' end,text from message
 where address='<phonenumber>' order by date;

Obviously you’ve got to find out the phone number (which is called address in the SMS database) of your conversation partner first and replace it for <phonenumber>. You also have to make sure the flags are associated correctly and replace <yourname> and <othername> with the names you want t. In my database (iOS 4.3.1) it seems that all incoming texts have flags=2, and my responses have flags=3 but this might not be universally true. Your conversation will be saved to <absolutefilename.txt>, which should be absolute as the naming implies.

You might have to start from the top and drill down first a little to find out the address / phone number of your conversation partner, and whether the above assumption about flags is correct:

select date,address,flags,text from message order by date;

If you don’t know the UDID of your iPhone, plug it into iTunes and Cmd-LeftClick in the serial number field on the device summary.

2 thoughts on “How to export SMS conversations from your iPhone into text

  1. about

    Do u know how to retrive sms from ios5? The file seems encrypted…
    But from itunes the “Encryption Option” is deselected! 🙁


Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see