Unindent every line

Unindent removes leading whitespace from each line. Remove All mode strips every leading space, tab, and other whitespace character. Remove N Levels mode strips a fixed indent symbol (default four spaces) up to Levels times. To put indent back on use indent text.

Input
Line 1:1 LF cloud_done Saved locally
Result Unindent Text
0 lines 0 chars

Two strip modes, one for surgical removal

Mode is the core control. Remove All (the default) runs line.replace(/^\s+/, '') on every line, which strips every leading whitespace character (space, tab, vertical tab, form feed, and Unicode whitespace). It is the easiest way to flatten arbitrary indentation back to column zero.

Remove N Levels is precise: it strips the Symbols string from the start of each line, up to Levels times. The default Symbols is (four spaces) and the default Levels is 1. So with the defaults a line starting with eight spaces becomes four spaces, a line starting with four spaces becomes empty, a line starting with three spaces is unchanged.

The strip is anchored to the start: line.indexOf(sym) === 0. If a line's leading run does not exactly match Symbols, the loop stops for that line. This means you can preserve mixed indentation safely (only the lines that actually start with your symbol get stripped). Set Symbols to \t for tab-only indents.

How to use unindent every line

  1. 1Paste your text into the input panel on the left.
  2. 2Pick a Mode: Remove All for any leading whitespace, Remove N Levels for a specific symbol.
  3. 3In Remove N Levels mode, set Symbols to the indent unit (default four spaces).
  4. 4Set Levels to the number of times to strip the symbol (1 to 40).
  5. 5Click Copy or Download in the output header.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

Remove All uses /^\s+/

Default mode. Every leading whitespace character is removed: spaces, tabs, vertical tabs, form feeds, Unicode whitespace. The line is left starting with its first non-whitespace character.

Remove N Levels matches your indent symbol

The strip is line.indexOf(sym) === 0 in a loop, up to Levels times. Symbols defaults to four spaces; set it to \t for tabs, (two spaces) for two-space code, or any custom marker.

Empty Symbols is a no-op

If Symbols is empty in Remove N Levels mode the input is returned unchanged. The strip needs a non-empty target.

Mismatched leading whitespace is preserved

In Remove N Levels mode the loop only strips when the line exactly starts with Symbols. So if your file mixes tab-indented and space-indented lines, only the matching ones are touched.

Reverse with the indent tool

Indent text is the natural inverse. Pair the same Length and Indent With there with Symbols here for a clean round trip.

Worked example

Mode Remove N Levels, Symbols four spaces, Levels 1. Each line loses one four-space level of indent.

Input
        function greet() {
            console.log('hi');
        }
Output
    function greet() {
        console.log('hi');
    }

Settings reference

Behaviour Effect on output
Mode = Remove All Strips every leading whitespace character via /^\s+/. Levels and Symbols are ignored.
Mode = Remove N Levels Strips Symbols from the start of each line up to Levels times.
Symbols populated The exact string used as one indent step.
Symbols empty Input passes through unchanged in Remove N Levels mode.
Levels (1-40) Maximum strip count per line. The loop stops as soon as the leading text no longer matches.
Mismatched indent Lines whose leading run does not start with Symbols are left untouched in Remove N Levels mode.
Line endings CRLF input becomes LF output.

FAQ

How do I remove tab indentation?
Use Remove N Levels mode with Symbols set to a single tab character. Set Levels to the number of tab levels to strip.
What is the difference between the two modes?
Remove All strips every leading whitespace character regardless of structure, flattening lines to column zero. Remove N Levels only strips when the leading text exactly matches your Symbols, preserving partial indents and mixed cases.
Does it preserve my non-leading whitespace?
Yes. Both modes only touch the start of the line. Spaces and tabs inside the line are untouched.
How do I add the indent back?
Use indent text. Pick the same Indent With kind and Length to mirror your Symbols here.
Does anything upload?
No. The transform runs in your browser. Your text never leaves the page.