Skip to content
TextRuns in your browser

Remove Extra Spaces

Remove extra spaces in one click — collapse repeats, trim every line, strip all whitespace or flatten line breaks.

Input
No upload needed — instant
Privacy
Nothing is uploaded
Cost
Free · no sign-up · no watermark

Loading tool…

The tool is loading its code on your device. This happens once and is cached for later visits.

Processed entirely on your device

Everything you type or paste is handled by JavaScript running in this tab. No request is sent, nothing is logged and nothing is stored. Close the page and it is gone.

Overview

About the Remove Extra Spaces

Remove extra spaces from text: collapse repeated spaces and tabs to one, trim every line, strip all whitespace, or flatten line breaks into a single paragraph.

Extra whitespace is the quiet defect behind a surprising number of problems: a search that fails because a value has a trailing space, a CSV column that will not match, a paragraph that looks ragged after a paste, a word count that is inflated by double spacing. None of it is visible, and all of it is annoying. This tool removes extra spaces from text in one click — collapse repeats, trim every line, strip all whitespace or flatten line breaks.

Where stray spaces come from before you remove extra spaces

PDFs and printed documents use spacing to justify text, so copying a paragraph often yields irregular gaps between words and hard line breaks at the edge of every column.

Word processors carry non-breaking spaces, tab stops and multiple spaces typed by hand — the classic “space after a full stop” habit produces double spacing throughout.

Web pages collapse whitespace visually but keep it in the source, so a copy from a rendered page can include indentation and newlines that never appeared on screen.

Spreadsheets and exports frequently pad values to a fixed width, leaving trailing spaces that break exact matches.

The three modes for removing extra spaces

ModeWhat it doesUse it when
Collapse extraRepeated spaces/tabs become one; lines trimmedGeneral clean-up of prose
Remove allEvery whitespace character deletedBuilding tokens, hashtags, keys
Flatten linesAll line breaks become single spacesUndoing PDF column breaks

Collapse is the default because it fixes the common case without destroying deliberate structure — your paragraphs and single spaces survive, and only the noise goes.

Why trimming matters when you remove extra spaces from data

In any exact-match context — a database lookup, a VLOOKUP, a de-duplication pass, a form validation — a leading or trailing space makes two otherwise identical strings different. Trimming whitespace before comparison is one of the first things a data-cleaning script does, and doing it here by hand is the quick equivalent for a list you are about to paste somewhere that will not forgive the extra characters.

A worked example, with the counters

Take three words out of a justified PDF, where the gaps have been stretched to fill the column: The quarterly report — two spaces after the first word, three after the second. Twenty-three characters, five of them whitespace.

Collapse extra returns The quarterly report: twenty characters, two of them whitespace, three cut. That is exactly what the four readouts show — Characters 20 (from 23), Whitespace left 2, Removed 3, Mode Collapse extra. Remove all would hand back Thequarterlyreport instead: eighteen characters, no whitespace at all, five cut.

The counters exist because whitespace damage is invisible. A paste that looks clean can still carry a trailing space on every line, and comparing the before and after numbers is the only honest way to know.

Invisible spaces that never came from the space bar

Unicode has more than a dozen characters that render as a gap. Web pages are full of   (U+00A0), which stops a line breaking in an awkward place. Typesetters reach for the thin space (U+2009) and the en and em spaces (U+2002 and U+2003) to fine-tune spacing. CJK text uses the ideographic space (U+3000), which is as wide as a character.

None of these match the [ ] pattern a naive clean-up uses, which is why they so often survive a trim and then break an exact match later: two strings that look identical on screen, one holding U+00A0 and the other U+0020, are different strings to a database and to a diff. All of them are rewritten as plain spaces here before the collapse runs, so what comes out is genuinely ASCII-spaced rather than merely tidy-looking.

When to use each extra spaces removal mode

A few scenarios: Collapse extra for general prose cleanup after a PDF paste; Remove all when building hashtags, tokens or keys that cannot contain any whitespace; Flatten lines to undo the column breaks that PDFs insert mid-paragraph. Each mode runs entirely in the browser, so contracts, transcripts and confidential documents are cleaned with no upload and no server round trip.

Step by step

How to use the Remove Extra Spaces

  1. Paste the text that has picked up stray spacing.

  2. Pick a mode: collapse extra spaces, remove all whitespace, or flatten line breaks.

  3. Watch the cleaned text and the count of removed whitespace characters.

  4. Copy the result or download it as a plain-text file.

Why use it

Benefits and common use cases

What this tool is good for, and what it deliberately does not try to do.

Fixes copy-paste damage

Text lifted from PDFs, Word documents and web pages arrives with double spaces, justified-text gaps, stray tabs and non-breaking spaces. Collapse mode fixes every one of those in a single pass; the hard line breaks a PDF leaves mid-sentence are what Flatten lines is for.

Three focused modes

Collapse repeated spaces to a single space and trim each line; remove every whitespace character to get one continuous run; or flatten all line breaks into a single paragraph.

See exactly what was removed

The stats report how many whitespace characters were in the source, how many remain, and how many were cut, so you can confirm the clean-up did what you expected.

Safe for sensitive documents

Everything runs locally. Contracts, manuscripts and transcripts are tidied in the page with no upload and no server round trip.

Questions

Frequently asked questions

Short, honest answers about quality, limits and privacy.

What does “collapse extra spaces” actually do?

It replaces every run of spaces and tabs with one space — a lone tab becomes a space too — trims both ends of every line, and squeezes any run of three or more line breaks down to a single blank line. The wording and the line structure are otherwise untouched, so your paragraphs survive.

Will it remove the spaces between my words entirely?

Only if you choose the “Remove all” mode, which deletes every space, tab and line break and leaves one continuous run of characters. The default collapse mode always keeps a single space between words.

How do I turn a multi-line paste into one paragraph?

Use the “Flatten lines” mode. It joins every line into a single paragraph, replacing the line breaks with one space, which is what you want when a PDF has broken a paragraph across many short lines.

Does it handle non-breaking spaces and tabs?

Yes, and that is deliberately the first thing that happens. Before any collapsing, every space that is not a plain U+0020 — the non-breaking space web copy is full of, the thin, en and em spaces typesetters use, the ideographic space from CJK text — is rewritten as an ordinary space. Tabs are then collapsed or deleted with the rest, so nothing survives as an invisible gap that looks fine on screen but breaks an exact match.