Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Remove Extra Spaces, Tabs and Line Breaks

Trim, collapse and strip spaces, tabs and line breaks.

Clean up

0 → 0 characters

Use via API

Trim lines, collapse repeated spaces, expand tabs, join lines or remove all whitespace from text. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/whitespace-remover

curl https://pithlab.com/api/v1/tools/whitespace-remover \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"  Too    many   spaces  \n\tand a tab  "}'

Fields and responseOpenAPI documentGet an API key

About the Whitespace Remover

Clean up messy text: trim lines, collapse repeated spaces, convert tabs to spaces, join lines by removing line breaks, or strip every whitespace character.

How to use the Whitespace Remover

  1. Paste your text into the input box.
  2. Choose what to clean: trim each line, collapse repeated spaces, convert tabs to spaces, or remove line breaks.
  3. Tick Remove all whitespace to delete every space, tab and line break, for example to tidy a copied number or code.
  4. The result updates as you type and shows the length before and after. Copy or download it.

Examples

Trim and collapse spaces

Input

   Hello     world   
  second    line 

Output

Hello world
second line
Join lines into one paragraph

Input

This sentence
was broken

across lines.

Output

This sentence was broken across lines.
Remove all whitespace

Input

GB29 NWBK 6016 1331 9268 19

Output

GB29NWBK60161331926819

Frequently asked questions

Which characters count as whitespace?

Spaces, tabs, line breaks and Unicode spaces such as the non-breaking space and em space. Collapsing replaces any run of two or more spaces or tabs with one ordinary space.

How does tab conversion work?

Tabs are expanded to the next tab stop, every 2, 4 or 8 columns, just like a code editor, so text that was aligned with tabs stays aligned with spaces.

What happens to blank lines when I remove line breaks?

Blank lines are dropped and the remaining lines are joined with a single space, so words from neighbouring lines don't run together.