Convert an exported WhatsApp chat (_chat.txt or .zip) into a clean, styled PDF — CLI + Python library.
Project description
whatsapp-chat-to-pdf
Convert an exported WhatsApp chat (_chat.txt or .zip) into a clean, styled PDF — from the command line.
A small, dependency-light tool for turning a WhatsApp chat export into a readable PDF
document. Available as a Python package (pip install whatsapp-chat-to-pdf) and a
Node / npm package (npx whatsapp-chat-to-pdf). Works offline, on your own machine — your
conversations never leave your computer.
💡 Don't want to install anything? If you'd rather drop in a chat export and get a media-rich PDF in your browser — with images, voice notes, emoji and pixel-perfect WhatsApp formatting — use the hosted converter at chattopdf.app. This CLI covers the text/offline case; the web app covers everything else.
Why this exists
Most open-source WhatsApp exporters output raw HTML or JSON. This one is built for the most common real-world need: a tidy PDF you can read, print, archive or email — a chat log, a keepsake, or a record for your files.
The hard part of parsing WhatsApp exports is that the _chat.txt timestamp format changes by
device, locale and language. This parser handles 14 timestamp formats out of the box,
including:
- iOS bracketed —
[2024/07/09, 08:01:49] Name: …and[2026-03-02, 6:39:22 AM] … - Android dashed —
3/15/24, 2:30 PM - Name: … - European dotted —
15.03.2024, 14:30 - Name: … - Dutch / Brazilian / Spanish iOS / ISO variants
- Non-Western numerals (Arabic, Persian, Devanagari/Hindi, Thai)
- CJK / Arabic / Persian AM-PM markers (上午/下午, 午前/午後, 오전/오후, ص/م, ق.ظ/ب.ظ)
It also correctly classifies media, calls, deleted and system messages, stitches multi-line
messages back together, and skips the macOS ._chat.txt resource-fork that silently corrupts
many other parsers.
Install & use
Python
pip install whatsapp-chat-to-pdf
whatsapp-chat-to-pdf _chat.txt -o my-chat.pdf
Or use it as a library:
from whatsapp_chat_to_pdf import parse_file, render
chat = parse_file("WhatsApp Chat with Alice.zip")
print(chat.message_count, "messages from", chat.participants)
render(chat, "alice.pdf", title="Chat with Alice")
Node / npm
npx whatsapp-chat-to-pdf _chat.txt -o my-chat.pdf
# or: npm i -g whatsapp-chat-to-pdf
import { parseText, render } from "whatsapp-chat-to-pdf";
const chat = parseText(fs.readFileSync("_chat.txt", "utf8"));
await render(chat, "out.pdf", { title: "Chat with Alice" });
How to get the _chat.txt export from WhatsApp
- Open the chat → tap the contact/group name.
- Scroll down → Export Chat → Without Media (or With Media for the
.zip). - Save the
.txt/.zipto your computer. - Run the command above.
(Full step-by-step with screenshots for iPhone & Android: chattopdf.app guide.)
Scope
| This CLI | chattopdf.app (hosted) | |
|---|---|---|
| Text → styled PDF, offline | ✅ | ✅ |
| 14 locale/date formats | ✅ | ✅ |
| Inline images & media | — | ✅ |
| Voice-note transcription | — | ✅ |
| Full emoji & CJK glyphs | — | ✅ |
| No install, runs in browser | — | ✅ |
Emoji and CJK render as the bundled DejaVu font allows; for full fidelity use the hosted version.
Contributing
Issues and PRs welcome — especially new timestamp formats from locales not yet covered.
Drop a sample of the offending _chat.txt header line in an issue.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whatsapp_chat_to_pdf-0.1.0.tar.gz.
File metadata
- Download URL: whatsapp_chat_to_pdf-0.1.0.tar.gz
- Upload date:
- Size: 742.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e250e40ed8304a941bd795cd77ac5ca45a29079d159293c8623f6b571ef599d6
|
|
| MD5 |
b8b88ac9fd7fcc1526fc15a1e849dd2b
|
|
| BLAKE2b-256 |
5eefdf18d712aef636c5b83120e8b55cfa0c635d2516034af9e7fe3475b52615
|
File details
Details for the file whatsapp_chat_to_pdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: whatsapp_chat_to_pdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 742.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
772984c51970f5a82c25fb1acaf2f21d188664ac6ffa5bc00ff46ec7a469820b
|
|
| MD5 |
daef68e6623bae366591512febe6c125
|
|
| BLAKE2b-256 |
06ec8a0b711c58b736e1bb41aba8ebdbc3631531f1706b855eee1c8c1685fb2e
|