chatpack 0.1.0

Compress chat exports from Telegram, WhatsApp, and Instagram into token-efficient CSV for LLMs
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

git clone https://github.com/berektassuly/chatpack.git

cd chatpack

cargo build --release

Binary will be at ./target/release/chatpack

Using Cargo

cargo install --path .

๐Ÿ“– Usage

chatpack <source> <input_file> [output_file]

Examples

# Telegram JSON export

chatpack telegram result.json

chatpack tg chat.json output.csv


# WhatsApp TXT export

chatpack whatsapp _chat.txt

chatpack wa chat.txt messages.csv


# Instagram JSON export

chatpack instagram messages.json

chatpack ig inbox.json chat.csv

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
WhatsApp TXT ๐Ÿ”ฒ Coming Chat โ†’ More โ†’ Export chat
Instagram 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

  1. Create src/parsers/newsource.rs:
use crate::core::InternalMessage;
use super::ChatParser;

pub struct NewSourceParser;

impl NewSourceParser {
    pub fn new() -> Self { Self }
}

impl ChatParser for NewSourceParser {
    fn name(&self) -> &'static str {
        "NewSource"
    }

    fn parse(&self, file_path: &str) -> Result<Vec<InternalMessage>, Box<dyn Error>> {
        // Your parsing logic here
        // Return Vec<InternalMessage { sender, content }>
    }
}
  1. Register in src/parsers/mod.rs:
mod newsource;
pub use newsource::NewSourceParser;

// In ChatSource enum:
NewSource,

// In from_arg():
"newsource" | "ns" => Some(Self::NewSource),

// In create_parser():
ChatSource::NewSource => Box::new(NewSourceParser::new()),
  1. Done! No changes needed in main.rs or processor.rs.

๐Ÿงช Running Tests

cargo test

๐Ÿ“ˆ 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/discord-parser)
  3. Implement the ChatParser trait for your source
  4. Add tests
  5. 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