How to extract your Facebook Messenger messages from a conversation
If you communicate with people (or bots) over FB messenger, you may find it useful to save a copy of your messages. You can do this by copy/pasting, but the output will be littered with "You sent", scrolling up is a pain, and you can't filter for only what you said.
Fortunately, Facebook provides data exports in JSON format, which we can then filter easily with the jq utility.
Go ahead, Request a Copy in the date range you care about, and select only "Messages":
Then extract from the archive the file messages/inbox/<your_friend>/message_1.json
. Once you have that file, here's how to filter all your messages, sorted chronologically by time:
cat message_1.json | jq -rc 'sort_by(.timestamp_ms) | .[] | select(.sender_name | contains("Dascalescu")) | .content'
(of course, replace "Dascalescu" with your name)
The -r
flag unquotes the strings. Useful to unescape "
s.
That's it!
Known issues
Characters are output as raw bytes. This will break non-ASCII characters and emojis. Check for solutions on StackOVerflow.