Fenced Code Block
``` ```python def greet(name): return f"Hello, {name}!" ``` ```
The language identifier (python, javascript, bash, etc.) enables syntax highlighting. Supported languages include: python, js, ts, jsx, tsx, html, css, json, yaml, bash, sql, go, rust, and dozens more.
Inline Code
For short code references within a sentence, use single backticks:
Use the print() function to display output.
Use inline code for variable names, function names, file paths, and short commands.
Common Language Identifiers
jsorjavascript— JavaScripttsortypescript— TypeScriptpyorpython— Pythonbashorsh— Shell/Terminaljson— JSONhtml— HTMLcss— CSSsql— SQL
Syntax Highlighting on Different Platforms
GitHub, GitLab, and MarkdownTools all support syntax highlighting with language identifiers. Discord renders code blocks but without highlighting — just monospace font.
Backtick Inside Inline Code
To show a backtick inside inline code, use double backticks as the delimiter:
backtick `
Indented Code Block (Legacy)
You can also create code blocks by indenting every line with 4 spaces. This is the old syntax — fenced backticks are preferred as they support language identifiers.
Full reference: Markdown Code Blocks.