MarkdownV2 escaper for Telegram bots

Telegram's MarkdownV2 parse mode rejects messages with any of _*[]()~`>#+=-|{}.! outside of valid syntax. Paste your message and we'll show you the escaped version that will actually send.

To escape special characters for Telegram MarkdownV2, prefix each reserved character (_ * [ ] ( ) ~ ` > # + - = | { } . !) with a backslash. Paste your message below and tgkit returns the escaped version that won't trip the "can't parse entities" error. Runs in your browser, no login.

Escaped output (paste into Bot API)

  

Preview (what Telegram will render)

Why MarkdownV2 is finicky

Telegram's original Markdown parser was lenient, extra characters were just ignored. MarkdownV2 (released 2020) is strict: every character in _ * [ ] ( ) ~ ` > # + - = | { } . ! must be either part of a valid markup token or escaped with a backslash. An unescaped one returns Bad Request: can't parse entities.

Reference, what needs escaping where

Inside normal textAll of _ * [ ] ( ) ~ ` > # + - = | { } . !
Inside `inline code`Backtick ` and backslash \ only
Inside ```pre block```Backtick ` and backslash \ only
Inside link/text-mention URLParens ) and backslash \ only

Common gotchas

Alternative: HTML parse_mode

If MarkdownV2's escaping is fighting you, switch parse_mode to HTML. You only need to escape < > &, and tags like <b>, <i>, <code>, <pre>, <a href="…"> work as expected.

Frequently asked questions

How do I escape special characters for Telegram MarkdownV2?
Prefix each reserved character with a backslash \. The reserved set is _ * [ ] ( ) ~ ` > # + - = | { } . !. tgkit's MarkdownV2 escaper does it for you: paste your message and it returns the version that will actually send without a parsing error.
Which characters need to be escaped in MarkdownV2?
These eighteen characters: _ * [ ] ( ) ~ ` > # + - = | { } . !. Inside pre and code blocks only ` and \ need escaping. Inside link URLs you only need to escape ) and \.
Why does my Telegram bot return 'can't parse entities' or 'character must be escaped'?
MarkdownV2 found an unescaped reserved character outside valid syntax (usually a period in a sentence, a hyphen in a date, or an exclamation mark). The error message tells you the byte offset; escape that character with a backslash, or run the whole message through an escaper before sending.
What's the difference between Markdown, MarkdownV2, and HTML in Telegram?
Markdown (legacy) is forgiving but limited; Telegram recommends not using it for new bots. MarkdownV2 is strict and supports more features (spoilers, nested formatting, custom emoji) but requires escaping. HTML is the cleanest if you generate output programmatically: only <, >, and & need escaping.

Related tools