Remove Extra Spaces
Clean up messy spacing in text.
Result
How it is calculated
The tool splits your text into lines at each line break, then on every line it replaces any run of spaces and tab characters with a single space and removes spaces at the start and end of the line. The lines are then joined back with ordinary line breaks. So the words and the number of lines stay the same, and blank lines stay as blank lines rather than being deleted. Only the plain space and the tab are handled: non-breaking spaces and wide spaces such as the ideographic space are left exactly as they are, as are line breaks inside the text. Empty input gives no result. Use it before pasting text into a form, a spreadsheet or code.
Worked example
Suppose you paste the text with 3 spaces at the start, 5 spaces between the first two words, 3 spaces between the last two and 3 trailing spaces: Hello world again. The tool collapses every run of spaces to one and trims both ends, which returns Hello world again. A tab between two words would be replaced by a single space in the same way.
Common mistakes
- Expecting blank lines to disappear. Empty lines are kept, so a gap of three blank lines stays three blank lines.
- Expecting non-breaking spaces from web pages or Word documents to be collapsed. They look like spaces but are different characters, and the tool leaves them alone.
- Using it to align columns. Collapsing runs of spaces removes the padding that made text columns line up.
- Applying it to code where indentation matters, such as Python or YAML, since leading spaces on every line are removed.
- Expecting line breaks to be joined into one line. Each line is cleaned separately and the breaks are kept.
About this calculator
This tool cleans up messy whitespace in a block of text by collapsing any run of repeated spaces or tabs down to a single space and trimming leading and trailing whitespace from each line, without touching the actual words or line breaks.
It is used to fix text that picked up extra spacing from copy-pasting out of a PDF, a formatted email, or an old document with inconsistent tabs, and by writers, developers and data-entry workers who need clean, normalized text before pasting it into a form, a spreadsheet cell, or code where stray whitespace can cause formatting or parsing problems.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Be careful with data copied from a spreadsheet. Rows pasted from Excel are separated by tab characters, and this tool turns every tab into one plain space, so the columns merge into a single line of text. Use it for prose, addresses and single cells, not for tables. Which kind of text do you usually need to clean up?