Colored text on Discord
Discord has the capabilities to display colored text through code blocks and syntax highlighting. The library discord uses for highlighting is highlight.js. Code blocks also supports ANSI which offers a more controllable coloring experience.
Features discussed in this page aren’t currently supported on mobile!
Ansi
Discord offers support for ANSI colored text through code blocks. To get started you need to copy the escape unicode character used (\u001b
). To copy the raw character use the copy button below.
Now that you know how to copy the escape character, Let’s go over how the ANSI is structured. To be able to send colored messages you need to use the ANSI language on a code block. After that, you need to make sure to use the correct format as a prefix before your text. \u001b[{format code};{ansi code};{ansi code}m
. We will go over the codes later on. To reset to default use the \u001b[0m
prefix.
Example message with the \u001b
character unescaped.
```ansi
[1;31;40mRed text with blue background.
```
ANSI Codes
Codes are split into 3 different categories. Format, text colors*, and background colors. You can set them in any order and set as many of them as you want. The last code will overwrite the ones before it.
Formats
0
. Default1
. Bold4
. Underline
Text Colors
30
. Gray31
. Red32
. Green33
. Yellow34
. Blue35
. Pink36
. Cyan37
. White
Backgrounds
40
. Firefly dark blue41
. Orange42
. Marble blue43
. Greyish turquoise44
. Gray45
. Indigo46
. Light gray47
. White
Syntax Highlighting
There is over 100 supported languages and only a few of them are showcased. In the code blocks you can specify language after three backticks ```language here```
.
The Code blocks on this page use a different color scheme. They are provided for ease of copying and testing different examples.
Bash
bash
, sh
```bash
'Light blue' or "Light blue" #Supports most characters. Works as long as it's inside either '' or "".
$Blue #Only the word starting with $. No special characters.
# Gray # Supports all characters after the hashtag.
echo exit break test # Colors most linux commands orange.
if elif then # Colors some reserved keywords red.
purple(){ # Colors words before (){ purple.
```
Diff
diff
, patch
```diff
*** Gray # All text after ***
--- Gray # All text after ###
*** 232,2212 ****
--- 1,9 ----
# ^^^ All decimal numbers marked with a comma inside either *** **** or --- ----
- Text with red background. # Everything after a hyphen.
+ Text with green background. # Everything after a plus sign or exclamation mark.
```
Toml
toml
, ini
```toml
[Dark blue text] # All text inside square brackets
; Gray # All text after a semi colon.
Blue = "Light blue" no true false yes 100 31.212
# ^^^ Word before equals sign will be blue any reserved words and numbers after it will be blue too. All text inside quotation marks will be light blue.
```
Json
json
```json
"Light blue" # All text inside quotation marks.
234 # Numbers blue
```
Fix
fix
```fix
All text blue
```
Markdown
markdown
, md
, mkdown
, mkd
```md
# Dark Blue. All text after hashtag letter.
Text above equal signs are Dark Blue.
==
Text above dashes are Dark Blue
--
> All Green after >
<Green> Words inside <> green.
<Green Blue="Light Blue">
* Yellow point.
1. Yellow ordered list.
[light blue][orange]
```
YAML
yaml
, yml
```yaml
- Unordered lists with light blue text and yellow hyphen.
1. Ordered list with a blue number and light blue text.
!Red !word !after !exclamation !mark
# Gray after hashtag
Blue text before a Colon:
```
SML (Standard ML)
sml
, ml
```sml
Capital Words Red
[] empty square brackets blue
list orange
```
Prolog
prolog
```prolog
Capital Words Orange
```
Useful Resources
Need help or have suggestions? Join our support server.
List and demo of all supported languages.
Great gist on ansi coloring.
Markdown guide with syntax highlighting examples.
Discord ansi color editor.