Discord ANSI Color Codes in Messages
Apply terminal-style color and bold formatting inside Discord messages using ANSI escape codes within a fenced ```ansi ``` code block.
Why / When to Use
When you want colored labels or styled output in a Discord bot message or notification — e.g. highlighting a status label like “Token Usage:” in gold, or color-coding severity levels.
Core Concept / Commands
Wrap content in an ```ansi block. ANSI sequences use \x1b[<code>m format. Reset with \x1b[0m.
# Example: Bold yellow label + plain value
line = f"```ansi\n\x1b[1;33mToken Usage:\x1b[0m {value}\n```"Common color codes
| Style | Code | Look |
|---|---|---|
| Bold Yellow | \x1b[1;33m | Warm, attention-grabbing |
| Bold Cyan | \x1b[1;36m | Clean, info-style |
| Bold White | \x1b[1;37m | Subtle but crisp |
| Bold Green | \x1b[1;32m | Positive / status |
| Bold Red | \x1b[1;31m | Error / critical |
| Reset | \x1b[0m | Return to default |
Full status line example (Python)
token_indicator = '🔴' if token_pct >= 80 else '🟡' if token_pct >= 50 else '🟢'
line = (
f"```ansi\n"
f"\x1b[1;33m⚡ Token Usage:\x1b[0m {token_indicator} "
f"\x1b[1;37m{token_pct}%\x1b[0m of {token_cap} tokens\n"
f"```"
)Gotchas
- Discord does not allow mixing ANSI blocks with regular markdown on the same line. Keep the entire styled line inside the
```ansi ```block. - ANSI rendering works in the Discord desktop and mobile apps; it may not render in older or third-party clients.
- Only color and bold/dim are supported — no italic, underline, or blink.
Source
Conversation: “Discord ANSI color codes in text” — 2026-05-17