whatsapp-chat-to-pdf
v0.1.0
Published
Convert an exported WhatsApp chat (_chat.txt or .zip) into a clean, styled PDF — CLI + library.
Maintainers
Readme
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.pdfOr 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-pdfimport { 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.
