Exporting chat history and what the JSON actually contains
Why this comes up
We run managed Telegram hosting and proxy setups for people who need their accounts to stay online and stable across sessions. A question that comes up more than you’d expect: “can I get my messages out before I do X” where X is switching devices, archiving an old account, or just wanting a local copy of something important. Telegram already has a built-in export tool. Most people never open it, and most guides that mention it don’t actually explain what’s in the file it produces. So here’s the real version.
Where the export tool lives
On Telegram Desktop, it’s under Settings > Advanced > Export Telegram data. It’s buried a few menus deep, which is probably why so few people know it exists. The mobile apps skip the granular version entirely, so if you want a full structured export, you need the desktop client.
When you open it, you get a set of checkboxes: personal chats, group chats, channels, contacts, and a few categories of account data like your profile photos and sessions list. You can also choose a date range, cap the size of media included, and pick between two output formats: JSON or HTML.
The HTML option is meant for humans. It renders your messages into browsable pages with a basic UI, good if you just want to scroll through an old chat visually. The JSON option is meant for machines, or for anyone who wants to actually parse the data programmatically. That’s the one worth understanding in detail, because it’s the one people misunderstand.
What actually triggers the export
The export runs locally, through the desktop client, using the session that’s currently logged in. Telegram’s servers don’t hand you a pre-packaged archive. Instead, the client pulls your message history over your existing connection, chat by chat, and writes it to disk on the machine you’re running it from. For text-only exports this is fast. If you include media and don’t cap the size limit, it can take a while, since every photo, video, and document gets downloaded chat by chat.
This matters for anyone running Telegram on a remote box, which is common if you’re managing an account through hosted infrastructure rather than a personal laptop. The export lands wherever the client is running. If that’s a remote session, the file sits on that machine’s disk until you move it. Worth knowing before you assume it’s saved locally on your own device.
The structure of result.json
The output is a single JSON file, typically named result.json, plus a folder of media files sitting alongside it if you included media. Text and structure live in the JSON. Photos, videos, voice notes, and documents are saved as actual files in subfolders, and the JSON just references them by relative path. Nothing is base64-encoded or embedded inline. That keeps the JSON itself readable and reasonably small even for chats with a lot of media.
At the top level, the file has a few sections: personal account info (your name, phone number in a normalized form, profile info), a list of contacts if you selected that, and then the chats themselves, each as an entry with a name, an internal chat ID, a type (personal chat, private group, supergroup, channel), and a messages array.
What’s inside each message
Each entry in the messages array is where the actual content lives. A typical text message includes:
id, a numeric message ID unique to that chattype, usuallymessageorservice(service messages are things like “X joined the group” or “chat title changed”)dateanddate_unix, both timestamps, one human readable and one as a unix integerfromandfrom_id, the sender’s display name and Telegram ID at export timetext, which is either a plain string or, if the message has formatting, an array of text entities
That last part trips people up. If a message has bold text, a link, or a mention, Telegram hands you segments rather than one raw string, each tagged with a type like plain, bold, italic, link, mention, or code. You have to reconstruct the display text yourself by concatenating the text field of each segment. It’s the same entity-based approach Telegram’s API uses internally for message formatting, just exposed here in the export.
Media messages carry additional fields: a photo or file path pointing to the downloaded asset, a mime_type, sometimes width and height for images, and duration for audio or video. Forwarded messages include a forwarded_from field naming the original sender or channel. Replies include reply_to_message_id, pointing back to another message’s ID in the same array, so you can reconstruct threads if you need to.
What’s not in there
A few things people assume are in the export but aren’t. Secret chats don’t export at all, by design, since they’re end to end encrypted and never touch Telegram’s cloud in the first place, which is also why the desktop client can’t pull their history the way it does for regular cloud chats. Your two factor password and login sessions aren’t included either. There’s no authentication material in the file, no session tokens, nothing that would let someone else log into your account just by having the JSON. It’s a data export, not a credentials dump.
Deleted messages aren’t recoverable through this either. The export only pulls what’s currently in your chat history at the moment you run it, the same way the app itself only shows you what’s still there. If a message was deleted on both ends before you exported, it’s gone from the JSON too.
Why the plain text matters
Because the whole file is plain JSON with no encryption applied to it, it’s only as safe as the disk it sits on. If you export on a shared server, a laptop that isn’t fully yours, or anywhere with backup software that syncs arbitrary folders to a cloud drive, that export goes wherever the disk’s normal file handling takes it. There’s no built-in protection layer once the data leaves Telegram’s servers and lands as a file.
This is the same logic we apply to account and session management generally: know exactly which machine holds which piece of sensitive data, and don’t let it sit somewhere by accident. If you’re exporting from a hosted session, move the file off that host and delete the copy once you’ve got it somewhere you control. If you’re pasting snippets of the JSON into an online viewer to debug something, remember that tool now has a copy of your message content too.
Practical uses that actually make sense
The most common legitimate reason to run this is a personal backup before deleting an account or switching to a new device where you don’t want to rely on cloud sync alone. It’s also useful if you need a structured, searchable record of a specific conversation, since the JSON is far easier to grep or parse than scrolling through the app. Some people use it for basic archiving of channels they run, keeping an offline copy of everything posted in case a channel gets suspended.
None of this requires anything beyond what Telegram already ships in the client. There’s no third party tool needed to get a complete export, and no reason to hand your login to anything outside Telegram’s own apps to get one.
Where that file ends up
The export tool is a normal part of Telegram, not a workaround or a gray area feature. The JSON it produces is straightforward once you know the entity structure for formatted text, and the media handling is sane, files on disk, references in the JSON, nothing embedded. The part worth actually paying attention to is where that file ends up sitting once it’s created, since nothing about the export process protects it after the fact.
If you’re managing Telegram accounts on infrastructure you don’t fully control day to day and want that handled properly, take a look at what we run at telegramvault.org.
Get new guides and videos first — join the Telegram channel.