Export Telegram chats to Markdown with Telethon.
Project description
telegram-to-markdown
Convert Telegram chats into human-readable and LLM-friendly Markdown, keeping it simple and informative.
Example output:
# Cat Chat
## 2026-04-18
### Luna · 09:12
mrrp~
### Milo · 09:13
coming meow
### Luna · 09:15
- Reply to: "coming meow"
Please bring the box.
### Coco · 09:18
- Forwarded from: Cat Notes
- Attached file: nap-plan.pdf
- Reactions: 👍 2, 😸 1
I shared the plan. Please check **bedroom naps**, _feeding time_, ~~old toy list~~, and [today's tasks](https://example.com/tasks).
### Nala · 09:21
- Attached photo
will be sleeping here
### Luna · 09:24
- Service: changed the chat title to "Sleepy Cat Chat"
Setup
As dependency
telegram-to-markdown is a Telethon package. Install with pip/uv/etc:
pip install telegram-to-markdown
Compatible with Folds bot framework (pass the bot as the client).
For one-off use
TGPy recommended for running scripts in Telegram :)
-
Install
telegram-to-markdownto the TGPy environment -
Run the snippet
from telegram_to_markdown import export await export(client, msg.chat, 'export.md', limit=100) await msg.respond(file='export.md') return 'Chat exported!'
Usage
from telegram_to_markdown import export
await export(client, chat, output_path, limit=1000)
- client: Telethon
TelegramClient - chat: username/link of any chat or ID/title of a known chat. "me" for saved messages
- output_path: optional output path or writable text stream
- limit: number of recent messages
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegram_to_markdown-0.1.0.tar.gz.
File metadata
- Download URL: telegram_to_markdown-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0acf083d64d11c2c5d2031262c3aadf315e3531a383042dd0a0274b295da347a
|
|
| MD5 |
7cca7c42e68022bfcef30dcac73c0fcb
|
|
| BLAKE2b-256 |
54ca6a2ce30b12497ca8010e117c252cba676da4580fc28384d2663e07aa1d92
|
File details
Details for the file telegram_to_markdown-0.1.0-py3-none-any.whl.
File metadata
- Download URL: telegram_to_markdown-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63547252cfaac37e51677ae063b49ea1930103e0784b4240e18bc8ec3ff25826
|
|
| MD5 |
c1bf191ffaedc379fa03932cbf91c0a0
|
|
| BLAKE2b-256 |
1c083338f8eade4ea605ac340eea8a4861b17e52409677957de7eae2180638d7
|