Discord Code Block Generator (Syntax Highlighting, Language List, Colors)
Code pasted into Discord turns into one ugly grey mess, and nobody remembers which language names give colours.
Hey there, bracket wrangler, your code is about to look sharp.
Picture sharing code in chat that is neat, coloured and easy to read.
This generator wraps your text in a code block with the right language name and shows a rough preview of the colours.
Short answer: To make a code block in Discord, type three backticks, the language name, a new line, your code, a new line and three backticks. Pick a language above and copy the ready block. Discord uses the language name to colour the code, so python, javascript and json get colours and plain text does not.
How do I make a code block in Discord?
- Type three backticks (the key under Escape, no Shift).
- Type the language name straight after them, like python.
- Press Shift and Enter for a new line, then paste your code.
- Add a new line and three more backticks, then send.
For a short bit of code inside a sentence, put a single backtick on each side instead: like this.
Which languages give syntax highlighting in Discord?
Discord colours code using the language name after the three backticks. These names work well.
| Language | Name to type |
|---|---|
| Python | python |
| JavaScript | javascript or js |
| TypeScript | typescript or ts |
| JSON | json |
| HTML and XML | html or xml |
| CSS | css |
| Java, C, C++, C# | java, c, cpp, csharp |
| Go, Rust, PHP, Ruby | go, rust, php, ruby |
| SQL and Bash | sql, bash |
| Diff (green and red lines) | diff |
| No colours | leave it empty |
Can I make coloured text with a code block?
Yes. A block with ansi as the language can show real colours with special codes, which the colored text generator on this site builds for you. The diff language makes lines that start with + green and lines that start with — red, which is a simple trick for two-colour messages.
Coloured code in chat has no right to feel this satisfying, and yet.
Why is my code block not coloured?
- The language name must come right after the backticks with no space.
- Check you used backticks, not apostrophes.
- Discord only colours languages it knows. A made-up name gives plain grey.
- Code inside the block that contains three backticks ends it early. The tool adds a hidden character to prevent that.
How long can a code block be?
A code block is part of a normal message, so it must stay under the 2,000 character limit (4,000 with Nitro). For a long file, use a pasting site and share the link, or split the code across messages.
Go share that snippet with style.
Sources and further reading
Questions and answers
How do I make a code block in Discord?
Type three backticks, the language name, a new line, your code and three backticks. Use Shift and Enter for new lines.
How do I get syntax highlighting in Discord?
Put the language name right after the first three backticks, for example python or javascript.
What is the backtick key?
The key under Escape on most keyboards, also called the grave accent, typed without Shift.
Can I put a code block on mobile?
Yes. Type or paste the three backticks, language and code, or paste the block copied from this tool.
Is my code sent to your site?
No. The block is built in your browser and nothing is sent anywhere.