npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clean-tg-chat

v1.0.1

Published

Removes useless information from JSON file with exported Telegram chat

Readme

Clean TG Chat

A lightweight CLI tool for cleaning exported Telegram chats. Removes unnecessary data while preserving the essential structure for analysis.

Features

  • 🔥 Reduces JSON file size by 3-10x
  • 📊 Preserves conversation structure (message replies)
  • 😀 Saves reactions with user information
  • 🎯 Keeps only essential fields for analysis
  • 🚀 Simple CLI interface
  • 📦 Zero dependencies

Installation

Global installation (recommended)

npm install -g clean-tg-chat

Local installation

npm install clean-tg-chat

Direct usage (no installation)

npx clean-tg-chat <input.json> [output.json]

Usage

Basic usage

clean-tg-chat result.json

Creates clean_chat.json in the current directory.

With custom output file

clean-tg-chat result.json cleaned.json

Using as a Node.js module

const { cleanChat } = require('clean-tg-chat');

// Synchronous cleaning
const cleanedData = cleanChat('result.json', 'cleaned.json');
console.log(`Processed ${cleanedData.messages.length} messages`);

// Asynchronous cleaning (Promise-based)
await cleanChat.async('result.json', 'cleaned.json');

What Gets Preserved

After processing, only these essential fields remain:

For each message:

  • id - unique message identifier
  • date - timestamp (ISO string)
  • from - sender name
  • text - message text (extracted from all formats)
  • reply_to_message_id - ID of replied message (if applicable)
  • reactions - message reactions (if any)

Reactions format:

{
  "emoji": "😁",
  "users": [
    {
      "name": "Username",
      "id": "user123456789",
      "date": "2026-01-12T19:52:39"
    }
  ]
}

Example Output

clean-tg-chat result.json

✅ Done!
📁 Saved to: clean_chat.json
💬 Messages: 145
👥 Participants: 2
↪️  Replies: 32
😀 Reactions: 15 (12 with user info)

Example reactions:
  😁: John
  👍: Mark

Data Preparation

How to export a chat from Telegram:

  1. Open the desired chat in Telegram Desktop
  2. Click ⋮ (three dots) → Export chat history
  3. Select format: JSON
  4. Uncheck Media (photos, videos, etc.)
  5. Export and get the result.json file

API Reference

cleanChat(inputPath: string, outputPath?: string): object

Synchronously cleans a Telegram chat export.

Parameters:

  • inputPath: Path to the input JSON file
  • outputPath: Optional output path (default: 'clean_chat.json')

Returns: The cleaned data object

cleanChat.async(inputPath: string, outputPath?: string): Promise<object>

Asynchronously cleans a Telegram chat export.

License

MIT

Support

Found a bug or have suggestions?

Compatibility

  • Node.js 12+
  • Telegram Desktop JSON exports
  • All operating systems (Windows, macOS, Linux)