chatpack-0.1.0 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 CSV for LLMs.
Less tokens. Same conversation.
โจ Features
- Token optimization โ Merges consecutive messages from the same sender, reducing token count by 30-50%
- Multi-platform โ Supports Telegram, WhatsApp, and Instagram exports
- Clean output โ Strips metadata (timestamps, IDs, reactions) leaving only sender and content
- LLM-ready โ CSV format with semicolon delimiter, perfect for feeding into AI models
- Fast โ Written in Rust for maximum performance
๐ Example
Before (62 messages):
[14:25] Alice: Hey
[14:25] Alice: How are you?
[14:26] Alice: Did you see the news?
[14:27] Bob: Hi! Yes I did
After (2 rows, 43.5% reduction):
Sender;Content
Alice;Hey
How are you?
Did you see the news?
Bob;Hi! Yes I did
๐ Installation
From source
Binary will be at ./target/release/chatpack
Using Cargo
๐ Usage
Examples
# Telegram JSON export
# WhatsApp TXT export
# Instagram JSON export
Options
| Flag | Description |
|---|---|
-h, --help |
Show help message |
-v, --version |
Show version |
Output format
- File:
optimized_chat.csv(default) - Delimiter: Semicolon (
;) - Columns:
Sender,Content - Encoding: UTF-8
๐ฑ Supported Sources
| Source | Format | Status | Export guide |
|---|---|---|---|
| Telegram | JSON | โ Ready | Desktop โ Settings โ Export chat |
| TXT | ๐ฒ Coming | Chat โ More โ Export chat | |
| JSON | ๐ฒ Coming | Settings โ Download your data |
๐๏ธ Project Structure
chatpack/
โโโ Cargo.toml
โโโ src/
โโโ main.rs # CLI entry point
โโโ core/
โ โโโ mod.rs
โ โโโ models.rs # InternalMessage struct
โ โโโ processor.rs # Merge logic + CSV writer
โโโ parsers/
โโโ mod.rs # ChatParser trait + factory
โโโ telegram.rs # โ
Implemented
โโโ whatsapp.rs # ๐ฒ Stub
โโโ instagram.rs # ๐ฒ Stub
๐ง Adding a New Parser
- Create
src/parsers/newsource.rs:
use crateInternalMessage;
use ChatParser;
;
- Register in
src/parsers/mod.rs:
pub use NewSourceParser;
// In ChatSource enum:
NewSource,
// In from_arg():
"newsource" | "ns" => Some,
// In create_parser():
NewSource => Boxnew,
- Done! No changes needed in
main.rsorprocessor.rs.
๐งช Running Tests
๐ Benchmarks
| Chat size | Messages | After merge | Reduction | Time |
|---|---|---|---|---|
| Small | 62 | 35 | 43.5% | <1ms |
| Medium | 1,000 | ~600 | ~40% | ~5ms |
| Large | 10,000 | ~5,500 | ~45% | ~50ms |
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/discord-parser) - Implement the
ChatParsertrait for your source - Add tests
- Submit a pull request
๐ License
MIT License โ see LICENSE for details.
๐ Acknowledgments
- Built for the AI era, where every token counts
- Inspired by the need to analyze chat histories with LLMs without burning through context windows