How to get syntax highlighting in Markdown code blocks
Short answer: use a fenced code block and put the language name straight after the opening backticks, for example ```python. Without that label, many renderers show the code plain.
Updated 15 October 2026. Syntax follows the CommonMark spec and GitHub’s documentation; Quire details come from its source code.
Write a highlighted block
- Open a fence
Start a line with three backticks (
```) or three tildes (~~~). - Name the language
Right after the fence, with no space needed, write the language:
```python,```js,```bash. Use lowercase. - Paste the code
Put the code on the following lines, unchanged.
- Close the fence
End with a line of the same characters, at least as many as you opened with.
In CommonMark the text after the opening fence is called the info string. Its first word is, by convention, the language. Markdown doesn’t define the list of names; each renderer decides which it knows.
Which language names work
- GitHub uses Linguist to pick grammars; the names and aliases in Linguist’s
languages.ymlare the valid ones. GitHub recommends lowercase names if the file will also be published with GitHub Pages. - Other tools use their own highlighter and their own list. Common names such as
js,ts,python,bash,json,yaml,html,css,sqlanddiffwork almost everywhere. Rarer ones vary.
Why a block stays plain
- No label. Some renderers guess; many, including Quire, don’t.
- An indented code block. Code indented by four spaces is a code block too, but it has no info string, so there is nowhere to name the language.
- An unknown name. A typo, or a language the renderer doesn’t bundle, falls back to plain text.
- A diagram fence.
```mermaidis drawn as a diagram by GitHub and some editors, and shown as code elsewhere. See viewing Mermaid diagrams.
To show a fence inside a code block, as in a Markdown tutorial, wrap the outer block in four backticks.
Highlighted code in Chrome
Quire Markdown is our extension, free on the Chrome Web Store. It highlights fenced code labelled with one of these languages, or a common alias for one: Bash, C, C++, C#, CSS, diff, Go, GraphQL, INI and TOML, Java, JavaScript, JSON, Kotlin, Less, Lua, Makefile, Markdown, Objective-C, Perl, PHP, Python, R, Ruby, Rust, SCSS, shell sessions, SQL, Swift, TypeScript, VB.NET, WebAssembly, XML and HTML, and YAML.

- Every code block gets a Copy button.
- Code it doesn’t know, unlabelled code, and any block over 50,000 characters stay readable as plain text.
- Highlighting works in the light and dark themes. A downloaded HTML copy keeps the code’s shading but not its colours.
- It is a viewer, not an editor, for UTF-8 files up to 2 MB.
Questions
Should I write ```js or ```javascript?
Both work in most renderers, including GitHub and Quire. Pick one and use it throughout your documents.
Can I highlight inline code?
Standard Markdown has no way to name a language for inline `code`. Some tools add their own syntax for it, which won’t carry over to others.