Skip to content

Shobon03/telegram-json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram JSON Parser

A simple, fast, and dependency-free command-line interface (CLI) tool written in Go to extract, deduplicate, and sort links from exported Telegram chat history JSON files.

Features

  • Link Extraction: Parses Telegram's exported JSON chat file format to extract all message text entities of type link.
  • Deduplication: Automatically filters out duplicate links to keep the list clean.
  • Sorting Options: Sort links alphabetically in ascending (-a) or descending (-d) order.
  • Multiple Output Formats: Export extracted links to a plain text file (.txt) with one link per line or as a formatted JSON array (.json).
  • Flexible Flag Parsing: Permits placing flags before or after positional arguments for a user-friendly CLI experience.
  • Automatic Filenames: Automatically generates a timestamped output filename (e.g., links-2026-07-18_19-34-12.txt) if no output path is provided.

Getting Started

Prerequisites

  • Go 1.21 or higher installed on your machine.

Installation / Compilation

Clone or navigate to the repository directory and build the binary:

make build

This compiles the code and creates an executable binary named tjson-parse in the root folder.

To clean up build artifacts:

make clean

Usage

./tjson-parse [flags] <input.json> [output]

Flags

Flag Description
-a Sort links in alphabetical ascending order.
-d Sort links in alphabetical descending order.
-json Output the result as a JSON array instead of a plain text file.

Note: -a and -d flags are mutually exclusive.

Examples

  1. Basic Extraction (outputs to a timestamped .txt file):

    ./tjson-parse result.json
  2. Extract and save to a specific output file:

    ./tjson-parse result.json links_output.txt
  3. Extract, sort ascending, and save as JSON:

    ./tjson-parse -a -json result.json

    (or using automatic file format extension deduction)

    ./tjson-parse -a result.json output_links.json

Input File Format

The tool expects the standard JSON format generated by the Telegram Desktop application when exporting chat history. Specifically, it searches for messages where the text structure contains elements with type "link".

Example Telegram export structure:

{
    "name": "Chat Name",
    "type": "personal_chat",
    "id": 123456789,
    "messages": [
        {
            "id": 1,
            "type": "message",
            "date": "2026-07-18T19:24:41",
            "text": "Check out https://github.com",
            "text_entities": [
                {
                    "type": "link",
                    "text": "https://github.com"
                }
            ]
        }
    ]
}

About

A link extractor for Telegram's exported JSON chat files.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors