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.
- 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.
- Go 1.21 or higher installed on your machine.
Clone or navigate to the repository directory and build the binary:
make buildThis compiles the code and creates an executable binary named tjson-parse in the root folder.
To clean up build artifacts:
make clean./tjson-parse [flags] <input.json> [output]| 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.
-
Basic Extraction (outputs to a timestamped
.txtfile):./tjson-parse result.json
-
Extract and save to a specific output file:
./tjson-parse result.json links_output.txt
-
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
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"
}
]
}
]
}