# Syntax
Code in Markdown: inline and fenced blocks
Last updated July 2026
To show code in Markdown, wrap a short snippet in single backticks for inline code, or put it between two lines of three backticks for a fenced code block. Inline code sits in the middle of a sentence. A fenced block stands on its own and keeps every line, space, and symbol exactly as you typed it.
Both do one job: tell Markdown "treat this as code, not prose." Otherwise characters like *, #, or _ get read as formatting. Backticks switch that off and show the raw text.
Inline code
Use inline code for a single command, a filename, a function name, or any short bit of code that lives inside a normal sentence.
Wrap it in one backtick on each side:
Run `npm install` first, then open `index.html` in your browser.
Now npm install and index.html appear in a monospaced font, set off from the words around them. Nothing inside the backticks gets formatted. An underscore stays an underscore instead of turning into italics.
Need a literal backtick inside your inline code? Wrap the whole thing in two backticks instead of one:
Use `` ` `` to start a code span.
The outer double backticks let the single backtick in the middle show as plain text.
Fenced code blocks
Use a fenced code block for anything longer than a word or two, or for code you want to keep on its own lines.
Open with three backticks on their own line, write your code, then close with three backticks on their own line:
```
function greet(name) {
return "Hello, " + name;
}
```
Everything between the fences is preserved as written. Line breaks and indentation stay put, and no character inside gets treated as Markdown. The block renders as its own box, separate from the paragraphs around it.
Adding a language name
Write a language name right after the opening three backticks. That labels the block so a reader can tell at a glance what they're looking at.
```python
def greet(name):
return f"Hello, {name}"
```
The word python never shows up in the code. It labels the block as Python, so a reader knows the snippet is Python at a glance. Common labels include js, python, swift, bash, json, html, css. Any language name works.
The label is optional. A plain fenced block with no language still renders as a code box, just without the label.
Tildes instead of backticks
If your code itself contains a line of three backticks, fencing with backticks would close the block early. The fix is to fence with three tildes (~~~) instead:
~~~
Here is a markdown example:
```
some code
```
~~~
Three tildes open and close a fenced block exactly like three backticks. Mix the two and you can show backtick fences inside a code block without breaking it.
In Unmarked
Both render. Inline code shows in a monospaced font, inline with your text. Fenced blocks render as their own box. In Read mode each block carries its language label and a copy button, so you lift the whole snippet out in one click instead of dragging to select it. Tilde fences behave exactly like backtick fences.
Unmarked is a free, private Markdown reader and editor for Mac. Read the story , or get in touch.