GhostTogether Gaming - Discord, Nitro and gaming guides - plus free Nitro every week

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?

  1. Type three backticks (the key under Escape, no Shift).
  2. Type the language name straight after them, like python.
  3. Press Shift and Enter for a new line, then paste your code.
  4. 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.

Discord code block generator: what goes in, the tool, and what comes out
How the tool works, start to finish.

Which languages give syntax highlighting in Discord?

Discord colours code using the language name after the three backticks. These names work well.

LanguageName to type
Pythonpython
JavaScriptjavascript or js
TypeScripttypescript or ts
JSONjson
HTML and XMLhtml or xml
CSScss
Java, C, C++, C#java, c, cpp, csharp
Go, Rust, PHP, Rubygo, rust, php, ruby
SQL and Bashsql, bash
Diff (green and red lines)diff
No coloursleave 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.

How this was written: The tool is our own and runs in your browser. Discord rules and limits mentioned here were checked against Discord’s help center and developer documentation (linked below) on December 4, 2026.

Oh, one more thing…

If this helped, you’ll like our free updates: the insights we discover while researching, and the moments worth sharing with other gamers — no spam, no promotions.

One short email when there’s something worth your time. Unsubscribe any time.