HomeMarkdown → Code

Code blocks in Markdown

Use single backticks for short inline snippets, and triple-backtick “fences” for multi-line code blocks. Add a language after the opening fence for syntax highlighting.

Inline code

Use `inline code` inside a sentence with single backticks.

Use inline code inside a sentence with single backticks.

Fenced code block with a language

Put the language name right after the opening ``` (e.g. python, js, bash):

```python
def greet(name):
    return f'hello {name}'
```
def greet(name):
    return f'hello {name}'

Plain fenced block

Omit the language for plain, unhighlighted text:

```
plain code block — no language, no highlighting
```
plain code block — no language, no highlighting

Good to know

Related: full cheat sheet · live editor.

Have a document instead of text?

Convert PDFs, Word, PowerPoint, Excel, and images into clean Markdown — free, no signup.

Convert a file to Markdown →