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
Note: Not tested on Windows.
You will need the following installed:
Step One: Getting Your Facebook Data
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 for
Messagesto lower the size of your download. The other options can be left default or customized to your liking. Click
Create Fileto 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.
Note that your Facebook data contains very sensitive information, so be careful storing it.
Step Two: Set Up ChatStats
- Clone or fork this repository:
git clone https://github.com/baieric/chatstats.git
- Install the dependencies:
pip3 install -r requirements.txt
Step Three: Generate Graphs!
- 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
Getting Started With the Codebase
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
# 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,
words, which are called by graphers in corresponding
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.