ChatStats is a data visualizer for a Facebook Messenger conversation. Try it out with your group chats or your significant other. You don't need to be an experienced programmer to use it!
ChatStats also works with group chats!
More examples can be found in my blog post.
- Average number of words per message
- Days with the most messages
- Each sender's most distinguishing words
- Each term's most distinguishing words
- Messages by hour of day
- Messages by term
- Messages by weekday
- Most frequent stickers
- Names said in chat
- Number of messages sent
And more!
Note: Not tested on Windows.
You will need the following installed:
To get your entire chat history:
- Go to https://www.facebook.com/dyi. Select "Download Your Information".
- On this page, change the Format option to
JSON
. You can deselect all information except forMessages
to lower the size of your download. The other options can be left default or customized to your liking. ClickCreate File
to continue. - Facebook takes a few minutes to generate a download link for you. Once you receive a notification from Facebook with a download link, save the file to your computer and unzip it. You can do Step Two while waiting for the file to download.
- You may be given more than one zip file. You must combine these zips when extracting in to one folder structure. (If you are interesting in contributing to ChatStats, automating this step would be awesome!)
Note that your Facebook data contains very sensitive information, so be careful storing it.
- Clone or fork this repository:
git clone https://github.com/baieric/chatstats.git
- Install the dependencies:
python3 -m pip install -r requirements.txt
(If this fails, try running with sudo
at the front.)
- Go to your Facebook messages folder, and find the folder containing the chat you want to use.
- Use the path of that folder to run the following command:
python3 chatstats.py <chat_folder>
This creates a folder in chatstats/my_data/
with your ChatStats graphs.
Have fun! If you need help deciding what conversations to try, sort your messages
folder by size. Try it out on all of your largest conversations!
There are some advanced options available in the file config.py
.
Facebook's Download Your Information tool sometimes updates the format of your data, which can break this tool. If you notice something, please file an issue or make a pull request!
Feel free to request a feature or make a pull request. There are ideas for bug fixes, improvements, and new graphs in the project roadmap.
To create a new graph, create a new Grapher
object in grapher.py
. The file has many examples to help you get started.
ChatStats uses graphers in this code snippet from chatstats.py
:
# generate graphs that use message data
messages = clean_data(pd.DataFrame(json_data["messages"]))
for grapher in message_graphers:
grapher.graph(messages, output_folder, parent_folder)
# generate graphs that use word data
words = word_data(messages)
for grapher in word_graphers:
grapher.graph(words, output_folder, parent_folder)
Here we create two different dataframes, messages
and words
, which are called by graphers in corresponding message_graphers
and word_graphers
lists. For ChatStats to use a newly created grapher, it must be added to the appropriate list.
If your graph is complex enough that it needs a new dataframe, create it along with a corresponding list of graphers that use it.
Thanks to my girlfriend, Camille, for motivating me to build this tool so we could look through our chat history together.
I'd also like to thank /u/sumisel on Reddit. Their /r/dataisbeautiful post was the inspiration for this project.