How to Format Text as a Block / Snippet of Code in Discord

Discord launched in late 2015 and quickly become a popular choice for gaming communities around the world. Today though, it’s not uncommon to find Discord being used by other communities with all kinds of interests.

Software developers, particularly those who contribute to open source projects, often use Discord as a collaboration tool. Discord even dedicates an entire page of their website to communities working on open source software.

In this article, we’ll take a look at how to format and send a block or snippet of code in Discord.

How to Format Text as a Block or Snippet of Code in Discord

With Discord’s text formatting, you can send a block or snippet of code with backticks on your keyboard. The backtick character is located just below the Esc key on your keyboard.

To send a snippet of code, simply type one backtick (`) followed by a single line of code and a closing backtick.

Discord Snippet of Single Line Code in Chatbox

To send a block of code in Discord, type three backticks (“`) followed by your code and a closing three backticks.

Discord Block of Code in Chatbox

Formatting Blocks of Code with Syntax Highlighting

You can also format blocks of code with syntax highlighting in Discord. Simply start a block of code with three backticks, like shown above, but immediately follow the last backtick with a language code (“`css). Don’t forget to end the block with three closing backticks.

Note: Language codes must be in all lower case and cannot have a trailing space after them. They will appear in green in the chat box before sending if done correctly.

Discord Block of Code with CSS Syntax Highlighting in Chatbox

Below is a list of some language codes available for syntax highlighting in Discord:

  • html
  • css
  • js (JavaScript)
  • json
  • java
  • coffeescript
  • php
  • py (Python)
  • cpp (C++)
  • cs (C#)
  • r
  • rust
  • diff
  • swift
  • yaml
  • sql
  • xml
  • xl
  • md (markdown)
  • asciidoc
  • autohotkey

See the highlight.js demo page for all supported languages.

Final Thoughts

Discord is a fantastic tool for having fun with friends or being productive with a team. When it’s time to focus, you might want to know how to appear offline in Discord to keep distractions to a minimum.

If you use Discord for both work and leisure, also check out our other article on running multiple instances of Discord at once.

Leave a Comment