What counts as an extra space
An extra space is any horizontal whitespace beyond the single separator the text actually needs: a second space after a period, a run of spaces used to fake alignment, a tab that survived a copy from a spreadsheet, a no-break space sitting next to an ordinary one, or padding left at the start and end of a line. On screen they are indistinguishable. In the stored text they are different code points, and they break different things later—search, exact comparison, wrapping, and column alignment.
One transformation handles all of them at once. Collapsing replaces each run of horizontal whitespace with one regular U+0020 space and trims the edges of every line, so word boundaries survive and only the surplus disappears. That is a different operation from deleting every space, which turns red apple into redapple, and from trimming, which changes line edges only.
How to remove extra spaces without joining words
- Open the Remove Spaces tool and keep a copy of the source text.
- Paste a representative sample—include your worst line, not an easy one—and read the whitespace audit.
- Choose Multiple Spaces, which is the default mode.
- Process the text, then compare the changed-character count with what the audit reported.
- Inspect at least one line that contained tabs, unusual spaces, or indentation.
- Copy the result only after confirming that intentional structure remains.
Multiple Spaces mode converts each supported run of horizontal Unicode whitespace to one regular U+0020 space, trims the beginning and end of each line, and preserves stored line breaks. It is the better default for sentences and paragraphs because it keeps a visible boundary between words.
Before:
The report[tab]contains extra gaps.
After collapsing:
The report contains extra gaps.What collapsing keeps and what it changes
| What the input contains | After collapsing | What to check |
|---|---|---|
| Two or more regular spaces in a row | One regular space | Nothing; this is the intended case |
| A tab inside or beside a space run | One regular space | Column alignment and TSV fields, which depend on the tab |
| NBSP, narrow no-break space, or another Unicode space | One regular space | Places where the no-break behavior was deliberate |
| Leading or trailing whitespace on a line | Removed | Indentation that carries meaning in Markdown or code |
| A single space between words | Unchanged | Nothing |
| Line breaks and empty lines | Unchanged | Nothing; vertical structure is a separate job |
Text where collapsing is safe
- Prose, notes, and articles pasted from a website or a PDF.
- Email and chat text that arrived with uneven spacing.
- Headings, titles, and form values carrying stray padding.
- Any text where a single space between words is the only separator that matters.
Text to review before collapsing
- Source code, Markdown, and YAML, where leading spaces are syntax.
- Fixed-width layouts, ASCII tables, and aligned reports.
- CSV, TSV, and other structured imports.
- Dates, units, product codes, and localized numbers held together by a no-break space.
- URLs and query strings, where a space may need
%20rather than deletion.
Where extra spaces come from
Knowing the source tells you how many surprises to expect in the rest of the file. Repeated spacing is rarely typed on purpose; it arrives with the text.
- Typing habits. Two spaces after a period is still muscle memory for many writers, and it survives every copy and paste.
- Copied documents. PDF and slide extraction turns layout into literal spacing, so one visual gap can be four or five characters.
- Spreadsheet and database exports. Padded cells keep their padding, and tab delimiters travel with the values.
- Rich text editors. Some editors write
runs to hold a gap open, which is why the extra space survives an ordinary find and replace. - Manual alignment. Spaces used to line up plain-text columns look like formatting until the text moves to a different font.
Check the result before you replace the original
- Keep the source. Collapsing is easy to repeat and impossible to undo once the original boundaries are gone.
- Read the audit first. Counts for regular spaces, tabs, no-break spaces, other Unicode spacing, and stored lines describe what the input holds, not what it looks like.
- Test the hardest line. An indented, tab-separated, or mixed-character line reveals problems that a clean sentence hides.
- Compare the counts. If many more characters changed than the audit predicted, the input contains a spacing type you have not accounted for.
- Paste into the destination. Confirm the result in the form, editor, spreadsheet, or system where the text will actually be used.
When a different transformation is the right one
Collapsing is one job. When the symptom is something else, a narrower tool changes less and is easier to review.
- No spaces at all. Choose All Spaces on the main space remover when an identifier or value must contain no horizontal separator, and keep the source, because joined words cannot be split again.
- Only the line edges are wrong. Trim Lines removes leading whitespace, trailing whitespace, or both while the spacing inside each line stays exactly as it was.
- Tabs are doing alignment work. Remove Tabs deletes, replaces, or expands tabs to real column stops, which matters for TSV data and indentation-sensitive code.
- The problem is vertical. Use Remove Line Breaks for hard wraps from a PDF or an email, and Remove Empty Lines for blank rows. Collapsing touches neither.
- A gap looks normal but behaves oddly. Identify the character before replacing it: read the Non Breaking Space guide and use the NBSP tool, or diagnose invisible code points with the zero-width character audit.
Frequently asked questions
How do I remove extra spaces but keep one space between words?
Choose Multiple Spaces. It collapses each supported horizontal whitespace run to one regular space and trims line edges, so words stay separated and only the surplus is removed.
Does removing extra spaces delete my line breaks?
No. Both modes on the main tool preserve stored line breaks. Vertical structure is handled separately by the line-break and empty-line tools.
What is the difference between extra spaces and all spaces?
Collapsing extra spaces leaves one separator between words. Removing all spaces leaves none, so red apple becomes redapple. The second is for controlled identifiers and compact values, not for prose.
Why are extra spaces still visible after replacement?
The gap may not be a regular space. Tabs, NBSP, typographic Unicode spaces, zero-width controls, or layout generated by the destination application can all survive a replacement. Use the audit to identify the stored category before choosing another transformation.
Can I safely remove extra whitespace from code?
Not with a broad text cleanup. Whitespace can separate tokens, define indentation, or preserve literal output. Use a language-aware formatter or a narrowly scoped change and test the code afterward. HTML is the common case: removing HTML spaces explains why source indentation, , and the CSS white-space property are three separate targets.
Reference
The WHATWG Infra Standard defines the operation this page describes. Its ASCII rule replaces each whitespace run with one U+0020 and then trims the edges—a useful model for why “collapse” and “delete every space” produce different results from the same input. See strip and collapse ASCII whitespace.