TextyConverterbeta
⌘K

Dedent Text

Remove common leading whitespace from every line. Auto-detects the minimum indent by default.

About Dedent Text

Dedent removes a common amount of leading whitespace from every line. By default it auto-detects the minimum indentation across all non-empty lines and removes that — the same behavior as Python's textwrap.dedent. You can also force a specific number of characters to strip.

When to use it

  • Cleaning up code that was copy-pasted with extra indentation
  • Normalizing a heredoc-style string in source code
  • Stripping the indent from a quoted block of text
  • Producing flush-left output from a hierarchical document

How it works

In auto mode, the tool scans every non-empty line and finds the smallest number of leading whitespace characters they all share — that count is stripped from every line. In manual mode, exactly N characters are removed from each line's start, but never more than the line actually has.

Examples

Common 4-space prefix is detected and removed
    foo
      bar
    baz
(auto)
foo
  bar
baz

Frequently asked questions

Are mixed tabs and spaces handled?
The auto-detect compares character-by-character: a leading tab is one character, a leading space is one character. If your lines mix the two, normalize first with tabs-to-spaces.
Are empty lines counted in the detection?
No. Empty lines don't constrain the minimum indent, matching the textwrap.dedent convention.

Related tools