Telegram Desktop allows you to export chats, but the export format is JSON.
If you’ve ever tried to open that JSON in Excel or Google Sheets, you know it’s basically unusable.
I ran into this problem when I needed to work with a Telegram chat outside of Telegram
(for analysis, archiving, and basic filtering), and the raw export just didn’t work.
Why Telegram exports are a problem
Telegram JSON exports have a few issues:
- Messages can be nested and formatted inconsistently
- Emojis and multiline messages often break spreadsheets
- System messages are mixed with real messages
- Large exports can crash Excel entirely
In practice, this makes Telegram exports hard to use for anything other than storage.
The basic idea of a solution
At a high level, the solution is simple:
- Load the exported
result.json - Iterate through the
messagesarray - Normalize each message into a flat structure
- Write everything to a properly quoted CSV
The tricky part is handling edge cases like:
- multiline text
- emojis
- media messages
- system/service messages
Minimal example
Here is a minimal example showing the general approach:
import json
import csv
with open("result.json", encoding="utf-8") as f:
data = json.load(f)
with open("chat.csv", "w", newline="", encoding="utf-8") as out:
writer = csv.writer(out)
writer.writerow(["date", "sender", "message"])
for msg in data.get("messages", []):
date = msg.get("date", "")
sender = msg.get("from", "Unknown")
text = msg.get("text", "")
if isinstance(text, list):
text = "".join(
t.get("text", "") if isinstance(t, dict) else t
for t in text
)
writer.writerow([date, sender, text])
##
This demonstrates the idea, but a production-ready solution needs to handle many more edge cases.
A practical solution
To avoid rewriting this logic every time, I packaged the full solution into a small offline Python CLI that converts Telegram Desktop exports into clean CSV files.
It handles emojis, multiline messages, system messages, and large exports, and produces a CSV that opens correctly in Excel and Google Sheets.
If you want the ready-to-use version, it’s available here: https://momentumguard.gumroad.com/l/ivyxn
Top comments (0)