How ANSI color codes work in Discord
Discord reads a small subset of ANSI escape sequences β the same control codes terminals have used for decades. Wrap them in a fenced code block tagged ansi and the client interprets them instead of printing them:
```ansi [2;31mThis line is red[0m ```
ESC is the invisible escape character (0x1B). You cannot type it on a normal keyboard, which is why most people either copy a message that already contains it or use a generator. Discord also requires the extra 2; prefix before the classic 30β37 and 40β47 codes β plain terminal ANSI without it renders as raw characters.
The 8 Discord ANSI color codes
Text colours use ESC[2;3Xm; the matching background is ESC[2;4Xm with the same last digit. Every row copies a block that shows both.
| Preview | Color | Text | Background | Hex | Copy |
|---|---|---|---|---|---|
| Black | ESC[2;30m | ESC[2;40m | #2a2d32 | ||
| Red | ESC[2;31m | ESC[2;41m | #ed4245 | ||
| Green | ESC[2;32m | ESC[2;42m | #57f287 | ||
| Yellow | ESC[2;33m | ESC[2;43m | #fee75c | ||
| Blue | ESC[2;34m | ESC[2;44m | #5865f2 | ||
| Pink | ESC[2;35m | ESC[2;45m | #eb459e | ||
| Teal | ESC[2;36m | ESC[2;46m | #1abc9c | ||
| White | ESC[2;37m | ESC[2;47m | #dcddde |
Black renders as Discord's dark grey rather than pure black, and White is a light grey β those are the actual palette values the client uses, so a black background always reads as a soft dark block.
Text style codes
Styles are separate sequences that stack on top of whatever colour is active.
| Style | Code | Notes | Copy |
|---|---|---|---|
| Reset | ESC[0m | Clears every colour and style that came before it. | |
| Bold | ESC[1m | Heavier weight. Supported on every Discord client. | |
| Italic | ESC[3m | Slanted text. Needs a reasonably recent client. | |
| Underline | ESC[4m | Underlines the text. Supported on every Discord client. | |
| Strikethrough | ESC[9m | Puts a line through the text. Newer clients only. |
24-bit truecolor (any RGB value)
Beyond the eight palette colours, recent Discord clients accept arbitrary RGB values:
- Text:
ESC[38;2;R;G;Bmβ for exampleESC[38;2;255;105;180mfor hot pink. - Background:
ESC[48;2;R;G;Bmβ for exampleESC[48;2;88;101;242mfor Discord blurple.
Truecolor sequences are much longer than ESC[2;31m, so on long messages they eat into Discord's 2000-character limit far faster. The eight palette codes remain the safest choice for anything lengthy.
Combining codes β worked examples
Cheat sheet β copy the whole block
```ansi [0m reset everything [1m bold [3m italic [4m underline [9m strikethrough [2;30m black [2;31m red [2;32m green [2;33m yellow [0m [2;34m blue [2;35m pink [2;36m teal [2;37m white [0m [2;40m bg black[2;41m bg red [2;42m bg green[2;43m bg yellow[0m [2;44m bg blue [2;45m bg pink [2;46m bg teal [2;47m bg white [0m [38;2;255;0;0m truecolor text [48;2;0;0;255m truecolor background ```
Client differences to know about
- Desktop, web and mobile all render the eight palette colours today. Very old mobile builds showed raw escape characters β updating the app fixes that.
- Bold and underline are the two styles you can rely on everywhere.
- Italic and strikethrough depend on client version; if they do not appear, the rest of the message still renders correctly.
- Truecolor support arrived later than the palette, so a handful of older clients fall back to the nearest palette colour.
- No Nitro required. Codes live inside a code block, which Discord renders for every account.
Related guides
- Discord Colored Text Generator β pick colours visually and copy a finished block, no codes to memorise.
- How to Make Colored Text in Discord (Copy and Paste) β the full walkthrough, including rainbow gradients and mobile.
- Discord Font Generator β Unicode text styles for when you want fancy lettering instead of colour.