Whitespace Tools

Clean up pasted text by trimming line edges or collapsing irregular spacing. Choose Trim or Normalize in tool settings before running.

  • Runs entirely in your browser
  • No data stored or sent to a server
  • Free forever — no signup
  • Instant conversion

Input and Output

Use the interactive encoder and decoder on this page to process your text.

Learn more about text

Trim and Normalize Whitespace in Text

Whitespace Tools

When to Clean Whitespace

Fix messy pasted text from PDFs, web pages, or spreadsheets. Choose Trim to remove leading and trailing whitespace per line, or Normalize to collapse irregular internal spacing.

Real-World Examples

Trim: remove trailing spaces from every line in a Makefile or YAML file

Normalize: collapse hello world to hello world

Prepare CSV or tab-separated data with consistent spacing

Common Mistakes

  • Normalizing indentation-sensitive formats like Python or YAML — use Trim instead
  • Expecting tabs to be preserved in Normalize mode — runs of tabs become single spaces
  • Trimming before comparing hashes — whitespace differences often cause false mismatches

Developer Tips

  • Trim log lines before deduplication for accurate matching
  • Enable Trim in CI pre-commit hooks for consistent text files
  • Switch modes in Tool Settings before clicking Run

Frequently asked questions

What is the difference between Trim and Normalize?

Trim removes leading and trailing whitespace on each line. Normalize additionally collapses consecutive internal spaces to a single space.

Are tabs affected?

Trim removes leading and trailing tabs on each line. Normalize collapses any run of whitespace (spaces, tabs, and similar characters) within a line to a single space.

Does this remove blank lines?

No. Use Remove Blank Lines for that. Whitespace tools only adjust spacing within or at line edges.