Whitespace Normalizer

Normalize duplicate spaces, tabs, Unicode spacing characters, line endings and repeated blank lines while preserving indentation when needed.

Processed locally in your browser

Prose collapses duplicate spaces and blank lines while normalizing line endings. Code-safe preserves tabs, indentation and repeated spaces. Compact text collapses whitespace aggressively and can remove structure.

Spaces
Tabs

One space is useful for prose. Fixed width inserts a set number of spaces. Tab stops calculate spaces from the current column and reset the column at each line break.

Line breaks and blank lines

U+0085 NEXT LINE and U+2028 LINE SEPARATOR convert to one LF. U+2029 PARAGRAPH SEPARATOR converts to two LF characters to keep a paragraph boundary.

The original input is preserved. Line and code-point positions in the change log are one-based.

Annotated preview of the original input (does not change the input):

Legend: · space, tab, line break, non-breaking or special space.

Normalize whitespace online

This whitespace normalizer normalizes ordinary spaces, replaces selected Unicode spacing characters, preserves or expands tabs, normalizes line endings, and limits repeated blank lines. It preserves code and indentation when requested, shows every important transformation in the change log, keeps the original input unchanged, and runs locally in the browser.

Whitespace normalization example

Rendered input (contains a real tab and duplicate ordinary spaces):

Name:	UnicodeNow  Tools


Status:   ready

Escaped representation:

Name:\tUnicodeNow  Tools\n\n\nStatus:   ready

Expected output with the Prose preset:

Name: UnicodeNow Tools

Status: ready

Expected summary: tabs replaced 1, duplicate spaces collapsed 2, blank lines collapsed 1, line endings normalized 0, special spaces replaced 0.

Special-space example, using real U+00A0, U+202F and U+3000 characters: Price: 100 EUR  today. With special-space replacement enabled this becomes Price: 100 EUR today, and each original code point is reported in the change log.

Remove duplicate spaces

Runs of two or more ordinary U+0020 spaces can be collapsed to one space in prose. Leading indentation may need separate preservation, and repeated spaces can be meaningful in code and tables, so prose mode collapses ordinary duplicate spaces while code-safe mode preserves internal spacing. Zero-width characters are never treated as ordinary spaces.

Replace tabs with spaces

Tabs are U+0009. One-space replacement is useful for prose text. Fixed-width replacement inserts a configured number of spaces for every tab. Tab-stop expansion depends on the current column and calculates only the spaces needed to reach the next stop, resetting at each line break. Code-safe mode preserves tabs by default, since Makefiles and some aligned text depend on real tab characters.

Normalize non-breaking and Unicode spaces

U+00A0 prevents line breaking. U+202F is a narrow no-break space. U+2007 is a figure space. U+3000 is an ideographic space. Replacing any of these with U+0020 removes their special spacing behavior, so every replacement is reported with its original code point. Zero-width spaces are handled separately by the Invisible Character Detector and Invisible Character Remover.

Normalize line endings and blank lines

Windows commonly uses CRLF, Unix-like systems use LF, and older text may contain a lone CR. Unicode also defines U+0085 NEXT LINE, U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR. CRLF, CR, NEXT LINE and LINE SEPARATOR all normalize to one LF, while PARAGRAPH SEPARATOR normalizes to two LF characters so that a paragraph boundary remains a paragraph boundary. Repeated blank lines can be limited to a configured maximum, including zero.

Preserve code, indentation and tables

Whitespace can carry syntax or alignment. Python and YAML depend on indentation. Markdown and plain-text tables depend on repeated spaces or delimiters. Code-safe mode preserves tabs, leading indentation and repeated internal spaces, and normalizes only line endings unless more is explicitly enabled. Compact mode can be destructive to this kind of structure, so review structured text carefully before switching presets or publishing.

Whitespace vs invisible characters

Ordinary and Unicode spaces create spacing or line boundaries. Zero-width spaces, joiners, bidirectional controls and variation selectors need different rules and are not removed by this tool. Use the Invisible Character Detector and Invisible Character Remover for those. C0 and C1 control characters are handled by the Control Character Remover.

How to use the normalizer

  1. Paste or type text into the input field.
  2. Choose a prose, code-safe, compact or custom preset.
  3. Configure spaces, tabs, line endings and blank-line limits.
  4. Run the whitespace normalizer.
  5. Review the normalized text, warnings and change log.
  6. Copy the normalized text or download the report.

Common use cases

Privacy and local processing

Normalization runs with JavaScript directly in your browser. Your pasted text is not submitted to UnicodeNow servers.

Frequently asked questions

What does whitespace normalization do?

It normalizes ordinary spaces, tabs, Unicode spacing characters, line endings and repeated blank lines, while leaving all non-whitespace Unicode characters exactly as they are.

How do I remove extra spaces from text?

Keep the default Prose preset and run the normalizer. Runs of two or more ordinary U+0020 spaces are collapsed to a single space.

Can the tool convert tabs to spaces?

Yes. Choose one space per tab, a fixed number of spaces per tab, or tab-stop expansion based on the current column. Code-safe mode preserves tabs by default.

What is tab-stop expansion?

It replaces each tab with the number of spaces needed to reach the next tab stop, based on the configured tab width and the current column on that line. The column resets at the start of every line.

Does it replace non-breaking spaces?

When special-space replacement is enabled, U+00A0, U+202F, U+3000 and other documented Unicode spacing characters are replaced with an ordinary U+0020 space, and each replacement is reported.

How are CRLF and CR line endings handled?

When line-ending normalization is enabled, CRLF is treated as one logical conversion to LF, and a lone CR is also converted to LF. Unicode NEXT LINE and LINE SEPARATOR convert to one LF, and PARAGRAPH SEPARATOR converts to two LF characters to preserve a paragraph boundary.

Can it remove extra blank lines?

Yes. Repeated blank lines can be limited to a configured maximum, including zero, while ordinary single line breaks remain unless a broader setting changes them.

Will it preserve indentation?

Yes, when leading-indentation preservation is enabled or the code-safe preset is selected. Leading spaces and tabs are left untouched by duplicate-space collapsing and line-edge trimming.

Is whitespace normalization safe for code?

Use the code-safe preset. It preserves tabs, leading indentation, repeated internal spaces and blank-line counts, and normalizes only line endings unless you explicitly enable more.

Are zero-width spaces treated as whitespace?

No. Zero-width spaces, joiners, bidirectional controls and variation selectors are not ordinary or Unicode whitespace. This tool preserves them and links to the Invisible Character Detector and Remover for that separate cleanup.

Is my text sent to a server?

No. Normalization runs with JavaScript directly in your browser; your pasted text is not submitted to UnicodeNow servers.

Related tools

To remove zero-width and hidden formatting characters, use the Invisible Character Remover. For broader cleanup and Unicode normalization, use the Unicode Text Cleaner. For copied PDF text, use Clean Copied PDF Text.

Control Character Remover

Remove control characters while optionally preserving tabs and line breaks.

Text CleaningProcessed locally

Unicode Text Cleaner

Normalize, trim and clean problematic Unicode text safely.

Text CleaningProcessed locally

Clean Copied PDF Text

Repair common spacing, hyphenation and line-break issues from copied PDF text.

Text CleaningProcessed locally