ToolMill.io

Whitespace Trimmer

Normalize messy whitespace in text by collapsing repeated spaces, tabs, or mixed space+tab runs into a single space. Useful for cleaning copied text from PDFs, emails, spreadsheets, and logs; formatting JSON/CSV headers; and fixing alignment issues caused by inconsistent tab/space usage. Choose whether to compress spaces, tabs, or both—output is generated separately so you can compare before/after safely.

Text

Try it

Examples

Compress spaces only
Input
a    b
Output
a b
Compress tabs only
Input
abc
Output
a b c
Compress mixed spaces and tabs
Input
a     b
Output
a b

How Whitespace Normalization Works

This page compresses repeated spaces, repeated tabs, or mixed runs of spaces and tabs into a single normal space depending on the option you select. It is meant for cleanup, not for preserving layout exactly. That is why the output is best thought of as a tidier working version of the original text.

Spaces vs Tabs vs Mixed Whitespace

Spaces-only mode compresses repeated spaces. Tabs-only mode compresses repeated tabs. The combined mode compresses any run made of spaces and tabs together. In every case, the replacement is a single ordinary space character, not a preserved tab.

What This Tool Changes and What It Leaves Alone

It changes selected horizontal whitespace runs only. It does not reorder lines, rewrite wording, remove punctuation, or perform broader document formatting. That narrower scope is useful when you want predictable cleanup without accidentally changing the text itself.

Example: Cleaning Pasted Spreadsheet and PDF Text

Copied text from PDFs and spreadsheets often contains uneven spacing that makes quick reuse awkward. Compressing those runs can make a rough export much easier to read before you paste it into a form, note, or another cleanup tool.

Example: Tabs Converted to Single Spaces

A common point of confusion is that tab compression still outputs normal spaces. That is intentional. The goal is consistent readable text, not preserving tab characters as layout controls in the cleaned result.

When to Use This Tool Before Other Text Cleanup

Whitespace normalization often makes later cleanup easier. After compressing spacing, you may find it simpler to compare lines, dedupe entries, parse fields, or paste the text into a CMS or spreadsheet without wrestling with inconsistent horizontal spacing.

Cases Where You Should Not Normalize Whitespace

Avoid this step when indentation, fixed-width alignment, code formatting, or tab-based structure actually matters. In those cases the repeated whitespace is part of the meaning or readability of the content, and compressing it can make the result worse.

Limits of Simple Whitespace Compression

Before You Rely on Trimmed Text in Code, Data, or Templates

Before replacing the original text, check whether indentation, alignment, tabs, or repeated spaces matter to the destination system. This page is useful for browser-local cleanup, but spacing-sensitive workflows should always get a final manual review before reuse.

When Whitespace Cleanup Can Change Parsing, Layout, or Meaning

Whitespace is not always cosmetic. In code, data files, templates, and copied tabular text, spaces and tabs can affect layout or even parsing behavior. A cleaned result may look nicer while still being wrong for the original destination if spacing carried functional meaning.

How to Interpret Trimmed Text Output

Trimmed output removes or normalizes extra whitespace to make the text easier to copy, compare, or reuse. That is often helpful for cleanup, but it also means spacing that once separated columns, alignment, or visual grouping may be simplified in the result.

This is a lightweight cleanup helper, not a document-format repair system. It cannot infer semantic structure, rebuild tables, or decide which spacing should remain for presentation reasons. It simply compresses the selected whitespace runs into one space.

Related tools