Text Transform

Remove spaces from text

What to do

Transformed in your browser · nothing is uploaded

Local · use collapse for prose instead
Advertisement
320 × 100

Strips every space, tab and line break so the text becomes one unbroken string, or collapses runs of whitespace to single spaces if that is what you meant. Non-breaking spaces count as whitespace here, which is the difference between this and a find-and-replace on the space bar.

How to use the remove spaces from text

1 Paste the value: a key, a card number, a hash.
2 Remove all whitespace is the default; collapse is the option for prose.
3 Check the character count under the result if the value has a known length.
4 Copy the unbroken string.

The reason this specific operation comes up so often is copy-and-paste from anything that wraps a long string for display: an API key shown across three lines in a dashboard, a card number printed in groups of four, a hash copied out of a terminal, an IBAN written the way a bank prints it. 4532 0151 1283 0366 becomes 4532015112830366, sixteen characters, and the counter under the result box confirms it. The line break in a wrapped copy is the nastier case, because pasted into a single-line field it is invisible: the value looks correct and the request comes back rejected.

One limit is worth knowing: whitespace is not the same as invisible. A zero-width space is not a space character at all, so it survives this untouched and will still break your comparison, while the byte-order mark that turns up at the front of a file exported from a spreadsheet does count as whitespace and is removed. If a value still refuses to match after the spaces have gone, run it through the text cleaner, which strips the zero-width characters too. And for prose this is the wrong option: it will happily glue every word together. Collapse is the one that keeps single spaces.

Questions

Yes, all of them. For prose use collapse, which keeps one space between words and trims each line.

MDN, working with strings
Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding