[{"data":1,"prerenderedAt":68},["Reactive",2],{"blog-post-discord-code-block":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":37,"related":42},"discord-code-block","Discord Code Blocks: Inline Code, Multi-Line Blocks and Syntax Highlighting","One backtick for inline code, three for a block, and a language name after the opening backticks for colors. Covers mobile, pasting backticks inside code, the 2,000 character limit and what code blocks switch off.","Discord has two kinds of code formatting, and both use the backtick character ( ):","2026-11-21","Reference","Matthew Rathbone","discord code block, discord code blocks, how to make a code block in discord, discord code formatting, discord syntax highlighting",5,"\u003Cp>Discord has two kinds of code formatting, and both use the backtick character (\u003Ccode>`\u003C/code>):\u003C/p>\n\u003Cpre>\u003Ccode>`inline code` inside a sentence\n\n```\na multi-line\ncode block\n```\n\u003C/code>\u003C/pre>\u003Cp>Both are in Discord&#39;s \u003Ca href=\"https://support.discord.com/hc/en-us/articles/210298617\">Markdown Text 101\u003C/a> help article: wrap text in single backticks for a one-line code span, and in three backticks for a multi-line block. Text inside is shown in a monospace font on a darker background, exactly as typed.\u003C/p>\n\u003Ch2 id=\"quick-reference\">Quick reference\u003C/h2>\n\u003Cdiv class=\"table-responsive\">\u003Ctable class=\"table\">\n\u003Cthead>\n\u003Ctr>\n\u003Cth>You want\u003C/th>\n\u003Cth>You type\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Code inside a sentence\u003C/td>\n\u003Ctd>\u003Ccode>`npm install`\u003C/code>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>A block of several lines\u003C/td>\n\u003Ctd>Three backticks, your lines, three backticks\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Colored syntax\u003C/td>\n\u003Ctd>Three backticks followed directly by a language name, such as \u003Ccode>js\u003C/code> or \u003Ccode>python\u003C/code>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>A backtick inside inline code\u003C/td>\n\u003Ctd>Use two backticks as the wrapper: \u003Ccode>`` a ` here ``\u003C/code>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Hidden code (spoiler)\u003C/td>\n\u003Ctd>Not possible. Discord states that spoilers inside code blocks are not hidden.\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\u003C/div>\n\u003Cp>The backtick is on the key to the left of \u003Ccode>1\u003C/code> on a US keyboard. On an iPhone, tap \u003Ccode>123\u003C/code> and hold the apostrophe key to get it. On Gboard, tap \u003Ccode>?123\u003C/code>, then \u003Ccode>=\\&lt;\u003C/code>.\u003C/p>\n\u003Ch2 id=\"multi-line-code-blocks\">Multi-line code blocks\u003C/h2>\n\u003Cp>Put three backticks on their own line, then the code, then three backticks again:\u003C/p>\n\u003Cpre>\u003Ccode>```\nSELECT name, email\nFROM users\nWHERE active = true;\n```\n\u003C/code>\u003C/pre>\u003Cp>On desktop, pressing Enter sends the message. Use \u003Cstrong>Shift + Enter\u003C/strong> to add a new line while you type the block.\u003C/p>\n\u003Cp>You can also keep a short block on one line: \u003Ccode>```like this```\u003C/code>. It still gets the block background, which is wider than inline code.\u003C/p>\n\u003Ch2 id=\"syntax-highlighting\">Syntax highlighting\u003C/h2>\n\u003Cp>Add a language name right after the opening backticks, with no space, then start the code on the next line:\u003C/p>\n\u003Cpre>\u003Ccode>```python\ndef greet(name):\n    return f&quot;Hello, {name}&quot;\n```\n\u003C/code>\u003C/pre>\u003Cp>Discord&#39;s help article does not list the languages it accepts. These are names that work in practice and cover most uses:\u003C/p>\n\u003Cdiv class=\"table-responsive\">\u003Ctable class=\"table\">\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Type this\u003C/th>\n\u003Cth>For\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>\u003Ccode>js\u003C/code>, \u003Ccode>ts\u003C/code>, \u003Ccode>jsx\u003C/code>\u003C/td>\n\u003Ctd>JavaScript and TypeScript\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>python\u003C/code> or \u003Ccode>py\u003C/code>\u003C/td>\n\u003Ctd>Python\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>json\u003C/code>, \u003Ccode>yaml\u003C/code>, \u003Ccode>xml\u003C/code>, \u003Ccode>html\u003C/code>, \u003Ccode>css\u003C/code>\u003C/td>\n\u003Ctd>Data and markup\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>bash\u003C/code> or \u003Ccode>sh\u003C/code>\u003C/td>\n\u003Ctd>Shell commands\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>sql\u003C/code>\u003C/td>\n\u003Ctd>SQL\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>java\u003C/code>, \u003Ccode>cs\u003C/code>, \u003Ccode>cpp\u003C/code>, \u003Ccode>c\u003C/code>, \u003Ccode>go\u003C/code>, \u003Ccode>rust\u003C/code>, \u003Ccode>php\u003C/code>, \u003Ccode>rb\u003C/code>, \u003Ccode>lua\u003C/code>\u003C/td>\n\u003Ctd>Other common languages\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>diff\u003C/code>\u003C/td>\n\u003Ctd>Lines starting with \u003Ccode>+\u003C/code> show green, lines starting with \u003Ccode>-\u003C/code> show red\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>md\u003C/code>\u003C/td>\n\u003Ctd>Markdown source\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>ansi\u003C/code>\u003C/td>\n\u003Ctd>Colored text with terminal escape codes\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\u003C/div>\n\u003Cp>Two things to know:\u003C/p>\n\u003Col>\n\u003Cli>\u003Cstrong>An unknown name is not an error.\u003C/strong> The block just renders without colors. If your code is not highlighted, check the spelling of the language.\u003C/li>\n\u003Cli>\u003Cstrong>A first line that is one word gets eaten.\u003C/strong> If a single word sits directly after the opening backticks and the rest is on the following lines, Discord reads that word as the language name and does not show it. Start your content on a new line.\u003C/li>\n\u003C/ol>\n\u003Cp>The \u003Ccode>diff\u003C/code> and \u003Ccode>ansi\u003C/code> blocks are how people get colored text on Discord, since there is no color syntax for normal messages. The \u003Ca href=\"/tools/discord-colored-text\">Discord Colored Text Generator\u003C/a> builds an \u003Ccode>ansi\u003C/code> block for you. Note that Discord does not document \u003Ccode>ansi\u003C/code> blocks, so test before relying on them.\u003C/p>\n\u003Ch2 id=\"what-a-code-block-turns-off\">What a code block turns off\u003C/h2>\n\u003Cp>Inside backticks, Discord stops interpreting everything else. That is useful and occasionally surprising:\u003C/p>\n\u003Cdiv class=\"table-responsive\">\u003Ctable class=\"table\">\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Inside a code block\u003C/th>\n\u003Cth>What happens\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>\u003Ccode>**bold**\u003C/code>, \u003Ccode>~~strike~~\u003C/code>, \u003Ccode>__underline__\u003C/code>\u003C/td>\n\u003Ctd>Shown literally, with the symbols\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>||spoiler||\u003C/code>\u003C/td>\n\u003Ctd>Not hidden (Discord says so in its Spoiler Tags article)\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>&lt;t:1796148000:F&gt;\u003C/code> timestamps\u003C/td>\n\u003Ctd>Shown as the raw code\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>[text](url)\u003C/code> masked links\u003C/td>\n\u003Ctd>Shown as typed\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Emoji codes like \u003Ccode>:smile:\u003C/code>\u003C/td>\n\u003Ctd>Shown as text\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\u003C/div>\n\u003Cp>This makes a code block the easiest way to show someone how to format something. Want to teach a friend spoilers? Send \u003Ccode>`||text||`\u003C/code> in inline code.\u003C/p>\n\u003Cp>It is also the standard way to post a table. Discord does not render Markdown tables, so the pipes and dashes show as plain text and the columns do not line up. Inside a code block the font is monospace, so an aligned table keeps its shape. The \u003Ca href=\"/tools/discord-formatter\">Discord Text Formatter\u003C/a> has a &quot;Clean up pasted Markdown&quot; button that converts a Markdown table (from ChatGPT, for example) into an aligned code block.\u003C/p>\n\u003Ch2 id=\"long-code-and-the-character-limit\">Long code and the character limit\u003C/h2>\n\u003Cp>Discord&#39;s \u003Ca href=\"https://support.discord.com/hc/en-us/articles/360034632292\">Sending Messages\u003C/a> article gives the cap as 2,000 characters per message, or 4,000 with Nitro. The backticks and the language name count. When a paste is too long:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Let Discord attach it:\u003C/strong> the same article says messages over the cap &quot;will be converted into a text file&quot;, which readers can expand in chat.\u003C/li>\n\u003Cli>\u003Cstrong>Split it:\u003C/strong> close the block with three backticks at a sensible line, then open a new block in the next message. Each message needs its own opening and closing backticks.\u003C/li>\n\u003Cli>\u003Cstrong>Link it:\u003C/strong> for anything longer than a screen, a gist or paste link is easier to read than five messages.\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"when-it-does-not-work\">When it does not work\u003C/h2>\n\u003Cdiv class=\"table-responsive\">\u003Ctable class=\"table\">\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Problem\u003C/th>\n\u003Cth>Cause\u003C/th>\n\u003Cth>Fix\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Backticks show as plain characters\u003C/td>\n\u003Ctd>You typed apostrophes (\u003Ccode>&#39;\u003C/code>) or a different quote character, or a phone keyboard substituted smart quotes\u003C/td>\n\u003Ctd>Use the real backtick. On iPhone, hold the apostrophe key.\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>The block never ends and swallows the rest of the message\u003C/td>\n\u003Ctd>Missing closing backticks\u003C/td>\n\u003Ctd>Add three backticks on their own line at the end\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>No colors\u003C/td>\n\u003Ctd>Misspelled language, a space after the backticks, or code on the same line as the language\u003C/td>\n\u003Ctd>Opening line must be exactly three backticks plus the language, then a line break\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Code contains three backticks (for example a Markdown file)\u003C/td>\n\u003Ctd>The inner backticks close the block early\u003C/td>\n\u003Ctd>Upload it as a file, or replace the inner fence while posting\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Extra blank line at the top\u003C/td>\n\u003Ctd>A blank line after the opening backticks\u003C/td>\n\u003Ctd>Start the code on the line right after the opening line\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\u003C/div>\n\u003Ch2 id=\"more-discord-formatting\">More Discord formatting\u003C/h2>\n\u003Cul>\n\u003Cli>\u003Ca href=\"/blog/discord-markdown-quickstart-guide\">Discord text formatting cheat sheet\u003C/a>: every option on one page\u003C/li>\n\u003Cli>\u003Ca href=\"/blog/discord-strikethrough\">How to strikethrough on Discord\u003C/a>\u003C/li>\n\u003Cli>\u003Ca href=\"/blog/discord-small-text-and-big-text\">Discord small text and big text\u003C/a>\u003C/li>\n\u003Cli>\u003Ca href=\"/tools/discord-spoiler-text\">Discord Spoiler Text Generator\u003C/a> and \u003Ca href=\"/tools/discord-timestamp\">Discord Timestamp Generator\u003C/a>\u003C/li>\n\u003Cli>General Markdown: \u003Ca href=\"/blog/markdown-code-block-syntax-highlighting-language-specification-complete-guide\">code blocks and language names\u003C/a>\u003C/li>\n\u003C/ul>\n",[15,19,22,25,28,31,34],{"id":16,"text":17,"level":18},"quick-reference","Quick reference",2,{"id":20,"text":21,"level":18},"multi-line-code-blocks","Multi-line code blocks",{"id":23,"text":24,"level":18},"syntax-highlighting","Syntax highlighting",{"id":26,"text":27,"level":18},"what-a-code-block-turns-off","What a code block turns off",{"id":29,"text":30,"level":18},"long-code-and-the-character-limit","Long code and the character limit",{"id":32,"text":33,"level":18},"when-it-does-not-work","When it does not work",{"id":35,"text":36,"level":18},"more-discord-formatting","More Discord formatting",[38,39,40,41],"discord-colored-text","discord-formatter","discord-spoiler-text","discord-timestamp",[43,52,60],{"slug":44,"title":45,"description":46,"excerpt":47,"date":48,"category":49,"author":10,"keywords":50,"readingMinutes":51},"markdown-syntax-highlighting-complete-guide","Markdown Syntax Highlighting: Complete Guide for Code Blocks","Master syntax highlighting in Markdown code blocks across platforms. Learn language identifiers, custom highlighting, and platform-specific features for better code presentation.","Code blocks are one of Markdown's most powerful features for technical writing, and syntax highlighting transforms plain code into readable, professionally formatted content. Understanding how to…","2025-08-18","Tutorial","markdown syntax highlighting, markdown code blocks, language highlighting, code formatting markdown, syntax coloring markdown, programming language markdown",8,{"slug":53,"title":54,"description":55,"excerpt":56,"date":57,"category":49,"author":10,"keywords":58,"readingMinutes":59},"how-to-add-line-numbers-to-code-blocks-in-markdown","How to Add Line Numbers to Code Blocks in Markdown: Complete Guide","Learn how to display line numbers in Markdown code blocks using GitHub, Jekyll, Hugo, and other platforms. Includes syntax highlighting and customization options.","Line numbers in code blocks significantly improve code readability and make it easier to reference specific lines in documentation, tutorials, and code reviews. While standard Markdown doesn't…","2025-08-13","markdown line numbers, code block line numbers, markdown syntax highlighting, numbered code blocks, markdown programming examples",6,{"slug":61,"title":62,"description":63,"excerpt":64,"date":65,"category":49,"author":10,"keywords":66,"readingMinutes":67},"markdown-line-numbers-code-blocks-complete-guide","Markdown Line Numbers in Code Blocks: Complete Guide for Enhanced Code Documentation","Master line numbering in Markdown code blocks for better code documentation. Learn platform-specific implementations, CSS styling, JavaScript solutions, and accessibility considerations for technical content.","Line numbers in Markdown code blocks transform simple code examples into professional, navigable documentation that enhances readability and enables precise reference communication. While standard…","2025-09-06","markdown line numbers, code block line numbers, markdown syntax highlighting, code documentation, technical writing, programming tutorials, code examples",21,1795332258307]