Exporting the iMessage conversations between you and another person
The iMessages app on Mac OS X lets your print your message history, but unless that history only spans a day or two back, scrolling back to load the history is a massive pain (even if you try to automate it with a drinky bird). Yet don't fret! The whole history of chats are stored in a database on your Mac.
Notices
- This requires a Mac.
- You will only be able to export the messages that have been received since your Mac was authorized to use iCloud (i.e. if you reformatted your Mac and reinstalled you won't get any old iMessages)
- This export will not contain any attachments (photos). There are links to these also included in the database but that's more difficult to extract. For adventurous users: look inside the message_attachment_join and attachment tables and in the ~/Library/Messages/Attachments directory
Steps
- Download and install Base 2 from Menial Ltd.
- In the Finder: In the "Go" menu select "Go to Folder" and enter "~/Library/Messages".
- Open the chat.db file in Base 2 (right click, open in).
- In the list to the left, under "Tables", select "handle".

- Select the "Data" tab at the top of the window.

- Note the ROWID for each "id" you want to export history from (they may be spread about phone numbers, iCloud accounts, AIM accounts, etc)
- Select the "SQL" tab in the top of the window.
- Enter this into the text field:
SELECT datetime(date+978307200,'unixepoch','localtime'), CASE WHEN is_from_me=1 THEN 'Sent' ELSE 'Received' END, text FROM message WHERE handle_id IN (3,108)
replace the numbers inside the parentheses at the end (in my example "(3,108)") with the ROWIDs you noted in step 5, separated by commas. Click Execute.
- Click the export to file button in the bottom of the window

- Make sure the "Text" tab is selected. Under Delimiter, select "Custom:" and enter a space into the text field. Click "Export...". If you want you can export to Excel instead and mess around with it in there to your liking.
- Select where to save it
- Done!