Markdown Nested List / Indentation Formatter

Paste a bulleted or numbered list with messy, inconsistent indentation and get back clean Markdown with consistent nesting per level. Handles mixed tabs/spaces and mixed bullet/numbered nesting. Free, no signup.

Preview

Markdown Nested List / Indentation Formatter

Paste a bulleted or numbered list with messy, inconsistent indentation — copied from Word, Google Docs, Slack, an AI chat response, or hand-typed with a mix of tabs and spaces — and get back a Markdown list with clean, consistent indentation per nesting level. Everything runs in your browser; nothing is uploaded.

Why inconsistent indentation breaks list nesting

Markdown doesn't nest list items by counting indent characters the way an outliner does — it infers nesting from indentation width, and different renderers are inconsistent about how forgiving they are. GitHub and GitLab generally expect roughly consistent 2–4 space indents per level; a stray tab character, an odd extra space, or indentation that varies between items at the "same" level can cause a sub-item to render as a sibling instead of a child (or vice versa). This is especially common when pasting from Word or Google Docs, which use their own internal indentation units that don't translate to a fixed number of spaces, or from Slack, which doesn't preserve list nesting in copied text at all.

The indentation-stack algorithm

Rather than assuming a fixed indent width (e.g. "every level is exactly 2 spaces"), this tool recovers each item's relative nesting depth from the original document, however ugly the source indentation is:

  1. Read each list item's leading whitespace and measure its width (a tab counts as 4 spaces for this measurement).
  2. Keep a stack of the indent widths seen so far, one entry per current nesting level. For each new line: pop any stack entries whose width is greater than the new line's indent (those levels have ended).
  3. If the new line's indent is wider than whatever is left on top of the stack, it's one level deeper than its predecessor — push it as a new level. If it matches the top of the stack exactly, it's a sibling at the same depth.
  4. The item's depth is simply its position in the stack once this is done.

This correctly recovers structure even when indentation widths are wildly inconsistent between items — 3 spaces here, a tab there, 5 spaces somewhere else — because it only cares about the order of indentation widths, not their exact values. One deliberate simplification: any increase in indentation, however large, is always treated as exactly one level deeper than the previous line, not as multiple skipped levels — this matches how the algorithm was specified and avoids guessing at intent from indentation size alone. Bullet and numbered markers are tracked completely independently of depth, so a bulleted list containing a nested numbered sub-list (or the reverse) nests correctly.

Once every item's true depth is known, the tool re-emits the whole list using your chosen indent size (2 or 4 spaces per level) and bullet character, so every level is finally consistent — regardless of how inconsistent the original was.

Being honest about ambiguous cases

Indentation-stack recovery isn't magic — it can only work from what's actually in the pasted text. If a line's leading whitespace mixes tabs and spaces, the 4-space tab-width assumption used above might not match what your source editor intended, which can shift that line's recovered depth by one level. This tool flags exactly which lines mix tabs and spaces so you can double-check them rather than silently trusting a guess. A blank line or a non-list line (a paragraph, a heading) in the middle of a pasted block resets the nesting stack, since at that point there's no reliable way to know whether a list item after it continues the previous list's structure.

Common use cases

  • Pasting from Word or Google Docs — their outline indentation doesn't map to a fixed number of spaces
  • Cleaning up AI-generated Markdown — chat responses are notoriously inconsistent about list indentation
  • Copying from Slack or chat apps — nesting is often flattened or indented with tabs
  • Standardizing docs before committing — make sure a README or wiki page uses one consistent indent width throughout

For more on writing nested lists and sub-bullets by hand, see our companion guide: Using Nested Lists and Sub-Bullets in Markdown.

Related tools