chatpack-0.2.1 is not a library.
Visit the last successful build:
chatpack-0.5.1
📦 chatpack
Compress chat exports from Telegram, WhatsApp, and Instagram into token-efficient formats for LLMs.
Why?
LLM context windows are expensive. A typical Telegram export is 80% metadata noise. chatpack strips it down to what matters: sender and content.
Before: 34,478 tokens (raw JSON)
After: 26,169 tokens (chatpack CSV)
━━━━━━━━━━━━━━━━━━━━━━━━
24% reduction ✨
Features
- 🚀 Fast — 20K+ messages/sec
- 📱 Multi-platform — Telegram, WhatsApp, Instagram
- 🔀 Smart merge — Consecutive messages from same sender → one entry
- 🎯 Filters — By date, by sender
- 📄 Formats — CSV, JSON, JSONL
Installation
Pre-built binaries (recommended)
Download the latest release for your platform:
| Platform | Download |
|---|---|
| Windows | chatpack-windows-x64.exe |
| macOS (Intel) | chatpack-macos-x64 |
| macOS (Apple Silicon) | chatpack-macos-arm64 |
| Linux | chatpack-linux-x64 |
macOS/Linux: After downloading, make it executable:
Via Cargo
Build from source
How to Export Your Chats
📱 Telegram (Desktop)
- Open Telegram Desktop (not mobile!)
- Go to Settings → Advanced → Export Telegram data
- Select the chat you want to export
- Important settings:
- ✅ Format: JSON
- ❌ Uncheck: Photos, Videos, Voice messages (saves space)
- ✅ Check: Text messages
- Click Export → Wait → Get
result.json
💬 WhatsApp (Mobile)
iPhone:
- Open chat → Tap contact name at top
- Scroll down → Export Chat
- Choose Without Media
- Send to yourself (email, AirDrop, Files)
Android:
- Open chat → Tap ⋮ (three dots)
- More → Export chat
- Choose Without media
- Save/send the
.txtfile
📸 Instagram (Web)
- Go to instagram.com → Log in
- Settings → Your activity → Download your information
- Request a download → Select Some of your information
- ✅ Check only Messages
- Format: JSON, Date range: All time
- Click Submit request → Wait for email (can take hours/days)
- Download ZIP → Extract → Find
messages/inbox/username/message_1.json
⚠️ Instagram exports have broken encoding (Mojibake). chatpack fixes it automatically!
Usage
Basic
# Telegram JSON export
# WhatsApp TXT export
# Instagram JSON export
Output Formats
# CSV (default) — best for token efficiency
# JSON — structured array
# JSONL — one JSON per line, streaming-friendly
Filters
# Messages after date
# Messages before date
# Messages from specific user
# Combine filters
Metadata Options
# Include timestamps
# Include message IDs
# Include reply references
# Include edit timestamps
# All metadata
Other Options
# Custom output file
# Disable message merging
Output Examples
CSV (default)
Sender;Content
Alice;Hey! How are you?
Bob;Good thanks! Just finished the project.
Alice;Nice! Let's celebrate 🎉
JSON
JSONL
{"sender":"Alice","content":"Hey! How are you?"}
{"sender":"Bob","content":"Good thanks! Just finished the project."}
{"sender":"Alice","content":"Nice! Let's celebrate 🎉"}
Technical Details
| Source | Format | Features |
|---|---|---|
| Telegram | JSON | IDs, timestamps, replies, edits, nested text |
| TXT | Auto-detect locale (US/EU/RU), multiline, system filter | |
| JSON | Mojibake fix, empty message filter |
Performance
Tested on 500MB files with toxic data (Zalgo, emoji spam, 100KB strings):
| Metric | Value |
|---|---|
| Throughput | 17-24K msg/s |
| Memory | ~2x file size |
| Max tested | 516 MB, 100K messages |
CLI Reference
chatpack <SOURCE> <INPUT> [OPTIONS]
Sources:
tg, telegram Telegram JSON export
wa, whatsapp WhatsApp TXT export
ig, instagram Instagram JSON export
Options:
-o, --output <FILE> Output file [default: optimized_chat.csv]
-f, --format <FORMAT> Output format: csv, json, jsonl [default: csv]
-t, --timestamps Include timestamps
-r, --replies Include reply references
-e, --edited Include edit timestamps
--ids Include message IDs
--no-merge Don't merge consecutive messages
--after <DATE> Filter: after date (YYYY-MM-DD)
--before <DATE> Filter: before date (YYYY-MM-DD)
--from <USER> Filter: from specific sender
-h, --help Print help
-V, --version Print version
Use Cases
Feed chat to LLM
# Then paste context.csv into ChatGPT/Claude
Build RAG dataset
# Each line is a document with timestamp
Analyze specific period
Export single person's messages