Text

Whitespace & Trim Tools

Clean up excess whitespace: trim line edges, collapse repeated spaces, remove empty lines, convert tabs ↔ spaces.

Extra whitespace — at line edges, doubled up inside text, blank lines, mixed tabs and spaces — is rarely visible at a glance, but it often breaks string comparisons, parsing, or how code looks. This tool cleans up such issues with a set of targeted operations.

How to use it

Common uses

Things to keep in mind

A non-breaking space ( , code point U+00A0) looks like a regular space but is a different character to a computer — strings containing it aren't equal to a regular space in comparisons.

Trimming line-edge whitespace doesn't touch spaces inside words or sentences — collapsing repeated internal spaces is a separate operation.

Article about this tool: Whitespace and invisible characters: the hidden cause of weird bugs

Frequently asked questions

What's the difference between trimming edges and collapsing repeated spaces?

Trimming edges only removes spaces at the start and end of each line, while collapsing repeated spaces replaces multiple consecutive spaces within a line with a single one, without touching the edges.

How are blank lines and tab/space conversion handled?

You can remove blank lines entirely or just collapse consecutive blank lines into one, and convert tabs to spaces or vice versa with a configurable tab width.

Is the pasted text sent to a server?

No, cleanup runs entirely in your browser in JavaScript, no data is transmitted elsewhere.

What are zero-width characters?

These are characters (zero-width space, zero-width joiner, and others) that take up no space on screen at all, yet are present in the text as distinct characters. They sometimes get copied in from certain websites and can silently break string comparison or search.

Why does a non-breaking space look like a regular space but behave differently?

A non-breaking space ( ) is visually identical to a regular space, but to a computer it's a different character — strings containing these two kinds of space are technically not equal in comparison, even if they look the same on screen.

Articles: Text

Case Converter: why different naming styles exist

Why one project writes variables in camelCase but files in kebab-case, and where these rules came from.

Text Diff: how algorithms find the difference between two texts

How a diff algorithm finds the minimal set of changes between two versions of a text.

Regular expressions: basic syntax and common patterns

How to read a regular expression, and how greedy matching differs from lazy matching.

Sorting and deduplicating lines: why it matters

Why numeric sorting putting "10" before "9" is a mistake, and how to avoid it.

String Escape: why the same text needs escaping differently

Why the same quote character gets escaped differently in a JS string, JSON, and a shell command.

CRLF vs LF: why line ending characters still matter

Why a file written on Windows can show as "entirely changed" in git on Linux.

Counting characters and words: why it's not always trivial

Why an emoji or an accented character can count as several characters at once.

Lorem Ipsum: where the placeholder text came from and why it exists

Why designers deliberately use "nonsense" text instead of real content in mockups.

Slugify: turning arbitrary text into a URL

How a title like "Hello, World!" turns into a URL-safe string like hello-world.

Markdown: why plain-text syntax beat rich text editors

Why developers choose to write documentation in Markdown instead of a rich text editor.

Text Reverse: why "reversing text" is harder than it sounds

Why a naive string reversal can turn an emoji into unusable bytes.

Text frequency analysis: why count how often words repeat

How letter frequency in ciphertext helps crack the simplest substitution ciphers.