Cadmeo

Remove Whitespace

77
Characters in
61
Characters out
16
Removed
5
Lines
Cleaned

Leading spaces here. Too many inner spaces. Indented line.

The whitespace remover offers six independent operations rather than one blunt strip: trim the whole text, remove leading or trailing spaces per line, collapse runs of spaces, collapse repeated blank lines, or remove every space and line break. Combine whichever you need and see exactly how many characters went.

How it works

The operations run in a fixed order, and that order matters. Line-based operations run before whole-text ones, and stripping everything runs last because it makes the rest irrelevant.

  • Collapse blank lines: runs of two or more blank lines become one.
  • Leading and trailing: spaces and tabs at the start or end of each line, applied per line rather than to the whole text.
  • Collapse runs: two or more consecutive spaces or tabs become a single space.
  • Trim: whitespace at the very start and end of the entire text.
  • Strip everything: every space, tab and line break, including the ones the other options would have preserved.

Only spaces and tabs are treated as inline whitespace. Non-breaking spaces survive, which is deliberate. They are usually there on purpose, and removing them silently breaks the typography they were added for.

Examples

Cleaning pasted text

Text

   Leading spaces.


Too   many    inner spaces.   

Options

Trim, trailing, collapse runs

Result

Leading spaces.


Too many inner spaces.

Collapsing runs fixed the inner spacing and trimming removed the outer padding, but the blank lines survived because that option was off.

Stripping everything

Text

a b
c d

Options

Strip every space and line break

Result

abcd

Six characters become four. This is what you want for comparing two strings that differ only in formatting.

Frequently asked questions

Why does turning on "strip everything" seem to ignore my other choices?

Because it runs last and removes all whitespace, including whatever the earlier options carefully preserved. The tool flags this when both are selected. The result is identical whether the others are on or off.

Are non-breaking spaces removed?

No. Only ordinary spaces, tabs and line breaks are touched. A non-breaking space is almost always deliberate (holding a number to its unit, or a name to a title) and stripping it silently changes how the text wraps.

What is the difference between trim and removing leading spaces?

Trim applies once to the whole text, removing whitespace before the first character and after the last. Removing leading spaces applies to every line, so indentation disappears throughout. Use trim for a stray paste, the per-line options to flatten indentation.

Will it remove the indentation from my code?

Yes, if you turn on "remove leading spaces on every line", which will break Python and YAML, where indentation is syntax. For code, collapsing runs and trimming trailing spaces are the safe options.

Compared with