Trim Whitespace

Free trim whitespace tool. Normalize runs of whitespace to single spaces, trim leading and trailing spaces, or remove all whitespace from text.

AI-ready Use this tool with AI

This tool has a free JSON API. Copy a prompt or skill below to use it with ChatGPT, Claude, or any AI agent — no API key needed.

API docs
Enter text above.

How trim whitespace works

Whitespace cleanup is a common text-processing step. Extra spaces, tabs, and newlines sneak in from copy-paste, exports, and formatting, and they break comparisons, searches, and parsing. Trimming or normalizing them produces clean, consistent text.

This tool offers three modes. Normalize (default) collapses every run of whitespace — spaces, tabs, newlines — to a single space and trims the ends. Trim removes only leading and trailing whitespace, keeping internal spacing. Remove deletes every whitespace character entirely, joining the text into one run.

Paste your text, pick a mode, and the tool returns the cleaned text with the size saving. Use it before data import, comparison, or search indexing, or to tidy pasted content.

Frequently asked questions

What does "normalize" do?
It collapses every run of whitespace (spaces, tabs, newlines) to a single space and trims the start and end, so " a b " becomes "a b".
What does "trim" do?
It removes only leading and trailing whitespace, leaving internal spacing untouched. " a b " becomes "a b".
What does "remove" do?
It deletes every whitespace character entirely, so "a b c" becomes "abc". Useful for things like phone numbers or identifiers that must have no spaces.
Does it handle tabs and newlines?
Yes. All whitespace — spaces, tabs, newlines, returns — is treated uniformly. Normalize turns them all into single spaces; remove deletes them all.