Markdown Syntax · Code

Markdown Code Blocks
Inline code, fenced blocks, and language highlighting

Code in Markdown runs on one character: the backtick. One backtick around a word makes inline code; three backticks above and below make a multi-line block. That's the whole idea.

AI answers are full of code blocks — ChatGPT and Claude fence almost every snippet — so understanding them helps you read, edit, and keep that code. This article covers inline code, fenced blocks, adding a language for highlighting, and why a block sometimes won't render.

New to the syntax overall? Start with How to Write Markdown.

The three ways to show code

Type How When to use
Inline code Wrap in single backticks A command, filename, or short snippet inside a sentence
Fenced code block Three backticks on their own line, above and below Multi-line code, kept exactly as typed
Fenced block + language Add the language name after the opening fence Multi-line code you want highlighted (where supported)

All together — note the backticks are the whole trick:

Inline code uses single backticks:
Run `npm install` first.

A fenced block uses three backticks, with an optional language:
```js
function hello() {
  console.log("hi");
}
```

The "js" after the opening fence sets the language for
syntax highlighting (in renderers that support it).

Inline code vs a fenced block

  • Inline code stays in your sentence — use it for a single command, a filename.md, or a short value. Wrap it in one backtick on each side.
  • A fenced block stands on its own — use it for anything multi-line. Everything inside is kept verbatim; Markdown formatting is switched off inside a code block, so your #, *, and _ show as-is.

Adding a language for highlighting

Write the language name right after the opening fence — js, python, bash, and so on. Renderers that support highlighting will colorize the code; the tag itself doesn't change anything, it just labels the language. It's optional, but it makes longer snippets much easier to read.

Why your code block isn't rendering

Symptom What happened Fix
Block didn't render as code The opening or closing fence is missing or uneven Put exactly three backticks on their own line, top and bottom
No syntax highlighting No language after the opening fence Add the language name right after the opening fence (js, python, …)
Code itself contains a fence Your code has a run of three backticks in it Fence the whole block with four backticks instead of three
Inline code cut off early A backtick appears inside your inline code Wrap it in double backticks so the inner one is literal

The number-one cause: an unbalanced fence. The opening and closing lines each need to be their own line of backticks, with nothing else on them — a stray space or a missing closing fence and the rest of your document turns into code.

Reading and writing code blocks with NoteLoom

Open a .md full of code in Notepad and you get a wall of raw backticks. NoteLoom is an editor that reads and writes local md files right in the browser: its reading view renders fenced blocks as clean monospace blocks, and its source view lets you get the fences right when you write them.

To be clear about the boundaries: NoteLoom has no AI — it won't write code, run it, or explain it. It opens, displays, and saves your local Markdown; the code is yours.

This comes up a lot with the rules files AI coding tools use — AGENTS.md and CLAUDE.md are full of commands and code. Open the folder in NoteLoom, read the blocks cleanly, and edit them in the source view — saved straight back to your disk, no cloud, no account.

FAQ

How do I write inline code in Markdown?
Wrap the text in single backticks. It renders in a monospace font, inline with your sentence — good for a command, a filename, or a short snippet. If the code itself contains a backtick, wrap it in double backticks so the inner one shows up literally.
How do I write a multi-line code block?
Use a fenced code block: a line of three backticks, your code on the lines below, then another line of three backticks to close it. Everything inside is kept exactly as typed — no Markdown formatting is applied inside a code block.
How do I get syntax highlighting?
Put the language name right after the opening fence — for example, three backticks followed by python or js. Renderers that support highlighting will colorize the code accordingly. The tag doesn't change the code; it just hints the language.
Why isn't my code block rendering?
Almost always the fence: the opening or closing line of three backticks is missing, indented oddly, or has stray characters. Put exactly three backticks (or more) on their own line, top and bottom, with nothing else on those lines.
My code contains three backticks — how do I show it?
Fence the block with more backticks than appear inside it. If your code contains a triple-backtick fence, wrap the whole thing in four backticks. The rule: the outer fence just has to be longer than any run of backticks inside.
Can NoteLoom help me read and write code blocks?
Yes. NoteLoom opens your local .md and renders fenced code blocks as clean monospace blocks in the reading view — much easier than raw backticks in Notepad — and lets you write or fix the fences in the source view. It has no AI: it won't write or run the code, just display and save your Markdown locally.
Can I do this with NoteLoom on my phone or in Safari?
Not for now. NoteLoom relies on the browser's File System Access API, which currently works in Chromium-based desktop browsers like Chrome, Edge, and Arc; Firefox, Safari, and mobile aren't supported yet.

Read your code blocks without the raw backticks

Open NoteLoom in Chrome / Edge / Arc, mount a local folder, and open any .md — the reading view renders fenced code cleanly, and the source view lets you fix the fences. Saved straight back to your disk, no software to install and no account to sign up for.

Open NoteLoom and try it