MD ViewerMD Viewer

100% private — everything runs in your browser

Markdown Indent

The same spaces mean three different things in Markdown. Switch between nested lists, indented code, and paragraph continuation — and see each markdown indent case render live.

MD Viewer Team

Examples
Markdown source
Preview
  • Fruit
    • Apple
      • Green apple
    • Banana
  • Bread

Markdown indent behavior is contextual: the same leading spaces can continue a paragraph, nest a list item, or turn text into a code block — depending on what came before. That is the trap. People indent for visual alignment and are surprised when the render shifts: a nested list appears, a paragraph joins a code block, or the indent quietly vanishes. The playground above lets you flip between all three cases of markdown indent behavior with one click and watch exactly what changes.

The three rules worth internalizing: two or three spaces (aligned under a list marker) nest list content; four spaces at the start of a new block make an indented code block; and leading spaces at the start of a normal paragraph are simply ignored — up to three of them — because markdown indent is not paragraph indentation. Between them sits the continuation case, where an indented line after a list item belongs to that item rather than the document.

This page renders each case with the same engine that powers the site's viewer, editor, and PDF export, so what you learn here holds everywhere. Try the examples, edit the sources, and use the explanations below to predict what any markdown indent will do before you commit it to a README.

Markdown indent: what the spaces become

You typeWhat the indent does
- item - child2-space markdown indent nests a list item under its parent
1. item 1. child3 spaces align under the marker text to nest ordered items
code here4 spaces at a block start create an indented code block
Paragraph more textUp to 3 leading spaces are stripped — not an indent
- item continuedAligned indent continues the item's paragraph

Using markdown indent deliberately

  1. 1

    Nesting lists: align under the text

    A markdown indent nests when it lines up beneath the parent item's first character — two spaces for - markers, three for 1. markers. Test in the Nested list example above until the alignment feels automatic.

  2. 2

    Code blocks: four spaces, blank line first

    Four leading spaces after a blank line flip Markdown into code mode — the markdown indent preserves monospace text verbatim. The Indented code example shows the same content with and without the flip.

  3. 3

    Paragraphs: indent nothing

    Leading spaces on a paragraph (three or fewer) are discarded. There is no paragraph markdown indent in the language — structure comes from blank lines, not alignment.

  4. 4

    Continuation: keep the item's rhythm

    Long list items wrap better when continuation lines carry the same markdown indent as the item text. They join the item in the render instead of drifting into a code block or a new paragraph.

Why markdown indent is contextual (and how to remember it)

Markdown parses documents as blocks, and each block type carries its own indent contract. A list block invites aligned markdown indent for nesting and continuation; a paragraph tolerates and discards it; a fresh block that begins four spaces deep is presumed to be preformatted code, a convention inherited from email quoting in the 1990s. The renderer never asks what you meant — it applies the contract of the block you are inside.

The practical memory hook is count-to-four. One to three spaces after a list marker: nesting or continuation. Four spaces in open space: code. Four spaces directly under a list item: nested code inside the item — which surprises people most, and which the Indented code example demonstrates harmlessly. When in doubt, prefer fenced code blocks with backticks over indented ones: fences are unambiguous, survive copy-paste, and declare a language for highlighting.

Once markdown indent clicks, list architecture stops being guesswork. Deep nesting alternates two and four spaces per level in practice; the markdown ordered list page adds numbering rules on top of the same alignment rules. Both pages share this site's live engine, so behavior you verify here is behavior you can trust there.

Markdown indent mistakes

1. Parent 1. Child (2 spaces)

1. Parent 1. Child (3 spaces)

Two spaces do not clear the three-character 1. marker, so the child merges into the parent line. A markdown indent must align under the text.

Paragraph indented line

Paragraph fenced or indented code

Four spaces directly after a paragraph continues it as plain text — but the same four spaces after a blank line become a code block. The blank line is the switch.

Leading spaces on a paragraph

No leading spaces

Paragraph-level markdown indent does not exist: up to three leading spaces are stripped on render. Use block structure, not alignment, to organize prose.

Indent survives the PDF

Nested lists keep their indentation levels and indented code keeps its monospace block through convert md to pdf — the export walks the same structure the preview renders, so a markdown indent you verify here prints the same way.

Frequently asked questions

Sources and spec citations

“An indented code block is composed of one or more indented chunks separated by blank lines.”
CommonMark Specification 0.31.2
“The contents of the code block are the literal contents of the lines, including trailing line endings, minus these four spaces of indentation.”
CommonMark Specification 0.31.2

Related Markdown tools