This repository contains a custom n8n node that converts Markdown into Telegram-compatible HTML.
It preserves Telegram-specific features (like spoilers using ||spoiler||) and formats standard Markdown into HTML that Telegram accepts.
Based on andresberrios/n8n-nodes-telegram-better-markdown.
This node is designed to:
- Accept a Markdown string and convert it into Telegram-safe HTML.
- Handle Telegram's 4096-character message limit intelligently.
- Allow customization of output field names and overflow strategies.
| Property | Type | Default | Description |
|---|---|---|---|
| Markdown Text | string |
— | The Markdown content to convert. |
| Output Field | string |
telegram_html |
Field name in the output JSON containing the generated HTML. |
| Message Limit Strategy | options |
truncate |
Strategy for handling messages exceeding Telegram's 4096-character limit. |
Telegram limits messages to 4096 characters.
This node provides two ways to handle longer content:
Behavior:
The generated HTML is truncated to a safe boundary (avoiding broken tags) and appends [...] to indicate omitted content.
Use Case:
When you only need one message output and can tolerate trimming the end.
Behavior:
The HTML is split into multiple parts (each ≤4096 characters).
Splitting preserves HTML integrity and returns multiple output items — one per chunk — with the same original data except for the updated Output Field.
Use Case:
When you want to send the entire message as multiple consecutive Telegram messages without breaking formatting.
- The node uses helper functions that tokenize HTML and prefer to cut at safe points (e.g., closed tags or line breaks).
- In
truncatemode, a[...]suffix is appended. - In
splitmode, each chunk becomes a separate output item — downstream nodes (like Telegram Send Message) will process each part independently.
{
"telegram_html": "<p>This is a long message... [...]</p>"
}A single output item is returned with truncated HTML.
[
{ "telegram_html": "<p>Part 1 of the message...</p>" },
{ "telegram_html": "<p>Part 2 of the message...</p>" }
]Multiple items are returned, each containing a valid HTML chunk.
npm installnpm run devnpm test -- --coverage --runInBand- Add the Markdown to Telegram-HTML node to your workflow.
- Provide your Markdown content in the Markdown Text field.
- Optionally change the Output Field name (default:
telegram_html). - Choose a Message Limit Strategy:
truncatefor a single, shortened message.splitfor multiple message chunks.

