How to Format Text with Markdown in Python Telegram Bot

I’m creating a Telegram bot using Python and having trouble with text formatting using markdown. The documentation isn’t clear about how markdown works in Telegram bots.

There are two different markdown modes available (Markdown and MarkdownV2) but neither one formats text the same way as when you type manually in a regular Telegram chat.

Here’s what I’m testing:

message_text = "*Bold text*, _italic text_, *_combined bold italic_*, **strong bold**, __strong italic__, __**all formatting combined**__"

bot.send_message(chat_id=user_id, text=message_text, parse_mode="Markdown")

With parse_mode="Markdown" I get: Bold text, italic text, combined bold italic, but double asterisks and underscores don’t work.

With parse_mode="MarkdownV2" I get: Bold text, italic text, combined bold italic, but still issues with double formatting.

In regular chat typing, the same string shows completely different results.

Can someone explain how to properly combine bold and italic formatting in Telegram bot messages? Are there other formatting options like underline available?

skip markdown - html formatting works way better. use parse_mode="html" with <b>bold</b> and <i>italic</i> tags. telegram’s markdown is buggy as hell, plus html gives you underline with <u>text</u>. way easier to deal with.

Regular Telegram chat uses a different markdown parser than the bot API - that’s why you’re seeing the difference. To combine bold and italic in bot messages, nest the formatting like this: *_text_*. Those double asterisks and underscores you’re trying don’t exist in Telegram’s markdown. MarkdownV2 is stricter - you’ll need to escape dots, hyphens, and other symbols with backslashes or it’ll break. I stick with single asterisks for bold and single underscores for italic since they work reliably in both modes. These formatting quirks are just how Telegram’s bot API differs from the regular client.