Convert WhatsApp chat export to PDF File
npm install whatsapp2pdfbash
npm install -g whatsapp2pdf
`
$3
`bash
npm install whatsapp2pdf
`
Requirements: Node.js 18.7 or higher
---
π Quick Start
$3
`bash
Basic conversion
whatsapp2pdf chat.zip
With options
whatsapp2pdf chat.zip -o my-chat.pdf --theme dark --images
Full help
whatsapp2pdf --help
`
$3
| Option | Description | Default |
|----------------------------|-------------------------|----------------|
| --list-themes | Display builtβin themes | - |
| -o, --output | Output PDF path | Auto-generated |
| -u, --main-user | Set rightβside sender | First contact |
| -p, --privacy | Hide contact names | true |
| -i, --images | Include attachments | true |
| -t, --theme | Theme: light / dark | light |
| --theme-path | Load custom theme JSON | - |
| -s, --start | Filter start date | - |
| -e, --end | Filter end date | - |
| -k, --keyword | Keyword filter | - |
| -v, --verbose | Debug info | - |
| -h, --help | Show help | - |
| -V, --version | Show version | - |
$3
`javascript
const WhatsApp2PDF = require("whatsapp2pdf");
// Simple conversion
await WhatsApp2PDF("./chat.zip")
.output("chat.pdf")
.convert();
// Advanced options
await WhatsApp2PDF("./chat.zip")
.theme("dark")
.mainUser("Your Name")
.seal() // Privacy mode
.images() // Include media
.searchDate("2024-01-01", "2024-12-31")
.output("chat.pdf")
.convert();
`
$3
.output(path) - Set output PDF path
.theme(name|path|object) - Set theme
.mainUser(name) - Set right-side sender
.seal(enable) - Partially hide contact names
.images(enable) - Include media
.searchDate(start, end) - Filter by date
.searchKeyword(keyword) - Filter by keyword
.verbose(enable) - Enable debug logging
.parse() - Parse without generating PDF
.convert() - Generate PDF
$3
WhatsApp2PDF.listThemes() - Get available themes
---
π¨ Features
$3
- β
Built-in Light & Dark themes
- β
Custom theme support (JSON)
- β
WhatsApp-authentic styling
$3
- π Partially hide contact names (e.g., "Alice" β "Al*ce")
- π Chat messages remain visible
- π Perfect for demos and presentations
$3
- π Filter by date range
- π Search by keywords
- π Extract specific conversations
$3
- πΌοΈ Images (JPG, PNG, GIF, WebP, HEIC, AVIF)
$3
- π Full emoji rendering
- π¨π³ Chinese (Simplified & Traditional)
- π―π΅ Japanese (Hiragana, Katakana, Kanji)
- π°π· Korean (Hangul)
---
β Architecture Diagram
`
[ CLI / API ]
|
v
+----------------+
| Parser |
| chat.zip/txt |
+----------------+
|
v
+----------------+
| Renderer |
| PDFKit + sharp |
+----------------+
|
v
output.pdf
`
π¨ Themes
$3
`bash
whatsapp2pdf --list-themes
`
#### Light Theme
`json
{
"background_color": "#EAE6DF",
"background_image": "./light.png",
"bubble": {
"color": "#D9FDD3",
"color_other": "#FFFFFF"
},
"fonts": {
"color": "#111B21",
"family": "Helvetica",
"size": 14
}
}
`
#### Dark Theme
`json
{
"background_color": "#0A1014",
"background_image": "./dark.png",
"bubble": {
"color": "#144D37",
"color_other": "#233138"
},
"fonts": {
"color": "#F7F8FA",
"family": "Helvetica",
"size": 14
}
}
`
#### Custom Themes
Theme JSON supports:
- background_color
- background_image (file / URL / base64)
- bubble styles
- fonts
- layout margins
- watermark
Use with:
`bash
whatsapp2pdf chat.zip --theme-path ./my-theme.json
`
---
π§ͺ Testing
`bash
npm test
`
---
π Troubleshooting
$3
`bash
node --max-old-space-size=4096 $(which whatsapp2pdf) chat.zip
`
$3
Install Noto Emoji font in assets/fonts/NotoEmoji.ttf
$3
Ensure ZIP contains a file starting with "WhatsApp Chat" and ending with .txt`