I have a long (several months' worth) iMessage conversation with a contact. He lost these messages when he re-installed his OS, but I still have the archive. There is some important information there that we'd like to keep.

Is there a simple way to export this conversation for archival in a human readable form, and also keep any images?

I can select parts of the conversation, copy it to the clipboard and paste it into a rich text document, but this discards all images. I'm looking for a way that keeps the images.

Note: I use iMessage on OS X only, not iOS.

(Ideally I'd also like to export all non-image file attachments, but I'm not expecting that this will be possible.)

  • 1
    Do you want to save them from an iDevice or a Mac ? Commented Nov 3, 2013 at 19:53
  • @MatthieuRiegler A Mac. I don't use iMessage on iOS, so I didn't think of that possibility. I'll update the question.
    – Szabolcs
    Commented Nov 3, 2013 at 19:53
  • 1
    Does apple.stackexchange.com/questions/88023/… help or are you looking for something else?
    – nohillside
    Commented Nov 3, 2013 at 19:54
  • @patrix I am looking for a way to get the messages out of iMessage, so I can view them even if I stop using OS X. I realize that it was a mistake to reply on iMessage to keep important information, so I want to move away from it completely, and hopefully salvage the chatlog for the future.
    – Szabolcs
    Commented Nov 3, 2013 at 19:58

6 Answers 6


If you know the iMessage account of your contact here is a bash script of mine to retrieve text + images.

#Parameter is a iMessage account (email or phone number i.e. +33616.... )
if [ $# -lt 1 ]; then
    echo "Enter a iMessage account (email of phone number i.e +33616.....) "

#Retrieve the text messages 

sqlite3 ~/Library/Messages/chat.db "
select is_from_me,text from message where handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='iMessage;-;$1')
)" | sed 's/1\|/me: /g;s/0\|/budy: /g' > MessageBackup.txt

#Retrieve the attached stored in the local cache

sqlite3 ~/Library/Messages/chat.db "
select filename from attachment where rowid in (
select attachment_id from message_attachment_join where message_id in (
select rowid from message where cache_has_attachments=1 and handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='iMessage;-;$1')
)))" | cut -c 2- | awk -v home=$HOME '{print home $0}' | tr '\n' '\0' | xargs -0 -t -I fname cp fname .
  • Thanks, this is useful. This won't give me the images though ...
    – Szabolcs
    Commented Nov 3, 2013 at 21:14
  • I'll dig a bit more to find them ;) Commented Nov 3, 2013 at 21:16
  • Thanks! I just found a solution which is good enough for now, so please don't spend your time on this any more.
    – Szabolcs
    Commented Nov 3, 2013 at 21:53
  • hi, how to run this script Commented Aug 8, 2014 at 11:35
  • stackoverflow.com/questions/25202168/… Commented Aug 8, 2014 at 11:39

I took the liberty of furthering the above answer by Matthieu. I wrote a script that would automate the process by backing up all the user's messages, including images, audio files, and movies--storing each conversation into a text file by phone number.


Edit: I developed the script into an OS X app with some nice features like contact recognition. https://peterkaminski09.github.io/baskup

  • What if the contact has no phone number?
    – Szabolcs
    Commented Jul 17, 2015 at 20:15
  • 2
    I retrieve all contact info from the chat table in ./Library/Messages/chat.db. This is not specific on user phone numbers. Just their id that is associated with their messages. In most instances this is in fact a phone number. Commented Jul 18, 2015 at 4:04
  • I used it. It worked. It was the only solution I found that didn't cost money. Thank you!
    – Erik Allen
    Commented Sep 4, 2018 at 2:21
  • I used it. It worked. Very nicely I should add. +1 'cos that's all I can give for a single answer.
    – Seamus
    Commented Sep 18, 2018 at 19:27
  • I used the script and it still works in Mac OS 15 Catalina. Thanks
    – james-see
    Commented Nov 4, 2020 at 17:11

I found a workable solution:

  1. Scroll up until all messages are loaded
  2. Print to PDF
  3. (If you have Acrobat,) crop off the margins from the pages to improve readability of split-across-pages messages.

The result doesn't look great, but it does contain all the images and the text is searchable. So it's good enough.

  • 4
    What if you have 25,000 messages in the conversation and scrolling up is not viable?
    – User
    Commented Jan 12, 2016 at 15:53
  • It takes a little time, but I think this solution is good for many use cases. Commented Jul 6, 2017 at 20:29


This person appears to have a more polished solution (no disrespect intended to the extremely useful SQLite scraper above):


To summarise the blog:

  • install Adium
  • choose the "import from iChat" option
  • Adium transcripts are generated from your logs and stored in:

    ~/Library/Application Support/Adium 2.0/Users/Default/Logs/

The converted files are in HTML, more easily readable and hopefully more archive-friendly, but the sqlite approach to attachment linkage looks sensible.


Note that iMessage attachments tend to live in:


(I don't know the rules for what goes in there and what doesn't, so it might not be complete - but there's a fair amount in there)

But actually you can see some information about the contact and conversation in the file's extended attributes:

$ xattr -lp com.apple.metadata:kMDItemWhereFroms <attachment>

will print an origin if Messages put one there on download.

  • 1
    Yes, @Szabolcs, I did see the "please don't spend your time on this any more" comment, but had to do a bit of digging of my own so thought I ought to share in case it's useful to someone else.
    – gra
    Commented May 6, 2014 at 18:10

Your mac should automatically save them. Here are instructions on how to extract them:


  • 1
    Welcome to Ask Different! Please don't give link-only answers. We're looking for answers that provide explanations of why it answers the question. Links can change over time and then we'll lose the question-answer context. See How to Answer for info on what makes up a good answer. - From Review -
    – fsb
    Commented May 27, 2016 at 0:18

Export iMessages app allows you to save, print, backup and recover SMS/iMessages to your Mac/PC.

  • 1
    This doesn't really answer the question as I explicitly said that I use iMessage only on OS X, not on iOS.
    – Szabolcs
    Commented Nov 12, 2015 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .