Skip to main content

CLI tool/library to parse, organize and export your Facebook message archives.

Facebook data can be downloaded via the link at the bottom of your settings page: https://www.facebook.com/settings

This library makes use of the messages.htm file located in the html/ directory inside your archive.

Why?

Facebook exports your messages as one gigantic HTML file. Messages are grouped into individual threads, though chats with a single person are broken up throughout the file, which reads oldest-to-newest. That’s annoying. This fixes that.

Installation

To install via pip, just run:

$ pip install fbparser

To install locally, from the same directory as setup.py, run:

$ python setup.py install

Example use

To export your threads to CSV, from the directory containing messages.htm, run this command:

$ fbparser --csv messages.htm

This will create a directory named fbparser_out/ in your current directory containing your CSV exports. Exports can also be made in JSON or plaintext formats (with --json and `--text), or printed to the console with --stdout

To specify your Facebook name (to remove from filenames), use the --name flag. If you specify your Facebook UID with --uid, that UID will be replaced with the name you specified. For example:

$ fbparser --csv --name="John Smith" --uid="12345@facebook.com" messages.htm

Everywhere 12345@facebook.com is found, it will be replaced with John Smith, which will also be removed from export filenames for clarity.

Replacing names/UIDs

Facebook’s archives are littered with UIDs and people that have changed their display names multiple times. To substitute certain names, feed in a file with --replace=file_name.txt

Example:

J Smith=John Smith
12345@facebook.com=John Smith
John H Smith=John Smith

Each line should be formatted like Name to replace=New name

FBParser merges threads containing the same users, so if you see numerous threads for the same person with different display names (or UIDs), this will correct those names prior to merging the threads.

Example:

$ fbparser --csv --uid="12345@facebook.com" --name="John Smith" --replace="replace.txt" messages.htm

Parsing errors

If you encounter errors trying to parse an archive, use the --sanitize flag. This creates a backup as messages.htm.bak and writes the new version to the original filename before attempting to parse the file.

Release files for fbparser 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fbparser 1.0.0
File Size Uploaded
fbparser-1.0.0.zip 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fbparser 1.0.0
File Interpreter ABI Platform
fbparser-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 kB

Release files / fbparser-1.0.0.zip

Download URL fbparser-1.0.0.zip
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
299606b5b8f8af9d9969cb844ad54d57851234a65530086a31daa56fbaa51d81
BLAKE2b-256 checksum
How to use checksums
a39b69262e61a69756ef4fbcc50261cd124f0ec797481b61844f3c233eb8cd98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fbparser-1.0.0-py3-none-any.whl

Download URL fbparser-1.0.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a4972163dd62ded9126f2aaa1f07bf225c9c3eb8442d2e8aa5e8447bfcc4c13
BLAKE2b-256 checksum
How to use checksums
a0dd5c2d22d6057fad8c2d8adec816c522330af34111f375391c36e461925c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page