The quick answer: Wrap code in triple backticks on their own lines. Add a language name after the opening backticks for syntax highlighting.
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
- `js` or `javascript` — JavaScript
- `ts` or `typescript` — TypeScript
- `py` or `python` — Python
- `bash` or `sh` — Shell/Terminal
- `json` — JSON
- `html` — HTML
- `css` — CSS
- `sql` — SQL
For the complete list of supported languages and syntax options, see the [Markdown code reference](/reference/code).
## 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](/reference/code-block).
Ready to put this into practice? Paste your markdown into the free [MarkdownTools PDF exporter](/markdown-to-pdf) or [HTML converter](/markdown-to-html) — no signup required.