Discord Text Color: ANSI Color Codes Explained (2026)
November 11, 2026 · 9 min read
Discord Text Color: How to Write Colored Text With ANSI Codes
Discord text color comes from ANSI escape codes inside a code block tagged ansi. You open the block with three backticks and ansi, put a short code such as [31m before your words, and the desktop and web apps paint them red. This guide lists the standard codes and fixes the invisible-character problem that breaks most copied examples.
How Does Discord Text Color Work?
Color isn't part of Discord's Markdown. Bold, italics, spoilers and headers are covered in our Discord Markdown cheat sheet. Color is a side effect of how Discord displays code blocks: when a block's language is ansi, the desktop and web clients read terminal color codes instead of printing them.
Each code, called an escape sequence, has three parts:
- The ESC control character (Unicode U+001B). It's invisible, and guides write it as
\u001b. - An opening bracket plus one or more numbers separated by semicolons, such as
[1;31. - The letter
m, which ends the sequence.
These are the same Select Graphic Rendition codes terminals have used for decades, documented in the ANSI escape code reference on Wikipedia. Discord supports only a small subset. If you want color in GitHub, Obsidian or HTML instead, that's a different technique, covered in Markdown text color. If it's a different typeface you're after, our Discord fonts guide explains what works.
Writing an ANSI Code Block Step by Step
A colored message needs four pieces in order: the opening fence, a color code, your text, and a reset code before the closing fence.
```ansi
\u001b[1;32mBuild passed\u001b[0m and the deploy is live.
```
In the desktop app this shows "Build passed" in bold green, followed by "and the deploy is live." in the default code color. Here's what each piece does:
- The opening line, three backticks followed by
ansi, starts the block and switches on color parsing. \u001b[1;32mturns on bold (1) and green text (32).\u001b[0mresets everything, so the rest of the line goes back to normal.- A line of three backticks closes the block.
Every \u001b in this post stands for the real, invisible ESC character. That detail is where most attempts go wrong.
Why Typing the Escape Code by Hand Doesn't Work
If you type the six characters \u001b[31m into Discord, you'll see exactly those characters in your message. Discord doesn't convert the backslash notation. It needs the actual ESC character, and your keyboard has no key for it.
The \u001b spelling only works in program source code. Python, JavaScript and most other languages turn that escape into the real character when they build the string, which is why bots get color without trouble. People typing in the app need another route:
- Copy from a builder. A Discord colored text generator puts the real ESC character on your clipboard, wrapped in the right codes.
- Reuse a block that already works. Copy a colored message you've sent before, or one from a community ANSI guide, and swap in your own words between the codes.
- Check the paste. Some text fields and phone keyboards may drop control characters. If your colors vanish after pasting, try pasting straight into the Discord desktop app.
When your message shows [31m with no backslash in front, the ESC character is usually missing. Recopy it from a source that includes it.
Discord Colored Text Codes for Text, Background and Style
The standard Discord colored text codes fall into three groups: styles (0, 1, 4), text colors (30 to 37) and background colors (40 to 47). Put any combination in one sequence, separated by semicolons.
| Code | What it does | Label in older Discord guides |
|---|---|---|
| 0 | Reset all styles and colors | Normal |
| 1 | Bold | Bold |
| 4 | Underline | Underline |
| 30 | Gray text | Gray |
| 31 | Red text | Red |
| 32 | Green text | Green |
| 33 | Yellow text | Yellow |
| 34 | Blue text | Blue |
| 35 | Pink text | Pink |
| 36 | Cyan text | Cyan |
| 37 | White text | White |
| 40 | Background, black slot | Firefly dark blue |
| 41 | Background, red slot | Orange |
| 42 | Background, green slot | Marble blue |
| 43 | Background, yellow slot | Greyish turquoise |
| 44 | Background, blue slot | Gray |
| 45 | Background, magenta slot | Indigo |
| 46 | Background, cyan slot | Light gray |
| 47 | Background, white slot | White |
The right-hand names come from Discord's original palette, as listed in the Python Discord color guide. Community testers reported in May 2026 that desktop Discord moved its backgrounds closer to standard ANSI colors. Exact shades depend on your client version and theme, so test before you rely on one.
Combining works the way you'd expect. \u001b[1;4;31m gives bold, underlined red text, and \u001b[1;40;37m gives bold white text on the darkest background. Gray (30) can be hard to read on the dark theme, so save it for low-priority notes. For notes like that outside a code block, Discord small text formatting is the native option.
How to Get Rainbow Text on Discord
Rainbow text is several color codes on one line, with a new code before each letter or word. Cycle through red, yellow, green, cyan, blue and pink, then reset at the end.
```ansi
\u001b[31mR\u001b[33ma\u001b[32mi\u001b[36mn\u001b[34mb\u001b[35mo\u001b[31mw\u001b[0m
```
This prints "Rainbow" with each letter in a different color. You don't need a reset between letters, because each new color code replaces the previous one. Coloring whole words instead of letters keeps the message shorter and easier to edit.
The kkrypt0nn ANSI guide now lists RGB text colors in the form 38;2;r;g;b, and its commenters report the feature reached more desktop users in October 2026. Discord hasn't documented this, so treat it as experimental and keep the eight standard colors as your default.
Using a Discord Colored Text Generator
A Discord colored text generator writes the codes and the hidden ESC character for you. Our Discord text formatter includes a colored text (ANSI) builder:
- Type the words you want to color in the "Text to color" box.
- Pick a text color (codes 30 to 37) and, if you like, a background (40 to 47).
- Turn on Bold or Underline if you need them.
- Click Insert into message to add the block to the formatter's message box, or Copy ANSI block to copy it alone.
- Paste it into Discord yourself.
The formatter runs in your browser, has no daily limit, and counts your message against Discord's 2,000-character limit. It never connects to Discord or posts anything for you. Its background menu uses the original Discord names from the table above.
We prefer a builder over hand-typing for anything longer than one colored word. The ESC character is invisible, so a single lost character silently breaks the whole line, and you won't see why until you've sent it.
Sending ANSI Colors From a Discord Bot
Bots have it easier, because the programming language inserts the real ESC character for you. In Python (discord.py) a normal string literal handles it:
message = "```ansi\n\u001b[1;31mBuild failed\u001b[0m on step 3\n```"
await channel.send(message)
Python turns \u001b into ESC and \n into a line break before the text leaves your bot. JavaScript string literals in discord.js behave the same way, and \x1b works as a shorter spelling in both languages.
The whole block counts toward Discord's message limit, including the fences and every escape sequence. A standard message holds 2,000 characters, or 4,000 with Nitro, so a letter-by-letter rainbow uses up space fast.
Does Colored Text Work on Discord Mobile?
As of November 2026, we couldn't find official Discord documentation for ANSI color. The community guides, including the Python Discord color guide linked above, say ANSI isn't supported on mobile, so the iOS and Android apps show an ansi block without color. Check on your own phone before you count on it.
That's the real limitation of colored text. You control what you send, not which app your readers open it in. Write messages that still make sense in plain grey: put "FAILED" in the words, and treat red as extra emphasis on top.
Old Highlighting Tricks: diff, fix and css Code Blocks
Before ANSI support, people colored text by borrowing other code languages and letting Discord's syntax highlighter do the work. The one still worth knowing is diff:
```diff
+ Server back online
- Old invite link expired
```
Lines starting with + usually show green and lines starting with - show red, because that's how diff output is highlighted. Tricks using fix, css, yaml or asciidoc blocks depend on the highlighter's theme. They have changed color over the years and may render inconsistently between clients. If you want to understand how fences and language tags work in general, our Markdown code block guide covers it.
Discord text color comes down to three things: an ansi code block, the right number codes, and a real ESC character in front of each code. Keep the meaning in your words so mobile readers still get it, and test new colors before an important announcement. When you'd rather not handle invisible characters yourself, build and copy the block with our free Discord text formatter.