String Utilities

Normalize Whitespace

Cleans up messy text by converting multiple consecutive spaces, tabs, and newlines into single spaces. Access via MCP in Cursor or Windsurf for AI-powered text processing, or hit GET /v1/string/normalize-whitespace directly. Perfect for sanitizing user input or preparing text for consistent formatting—handles Unicode whitespace characters beyond just ASCII spaces.

API Endpoint

GET /v1/string/normalize-whitespace

Code Examples

curl "https://tinyfn.io/v1/string/normalize-whitespace" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/normalize-whitespace', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/string/normalize-whitespace',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's string tools:

{
  "mcpServers": {
    "tinyfn-string": {
      "url": "https://tinyfn.io/mcp/string",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What types of whitespace does normalize-whitespace handle?

Handles all Unicode whitespace: spaces, tabs, newlines, carriage returns, non-breaking spaces, and other Unicode space characters. Converts consecutive whitespace sequences to single ASCII spaces.

How do I use normalize-whitespace with MCP in my AI workflow?

Call the tool from Cursor, Windsurf, or other MCP clients to clean text before processing. Useful when AI agents need to standardize user input or prepare text for consistent analysis.

Does normalize-whitespace preserve leading and trailing spaces?

No, it trims leading and trailing whitespace entirely. Only internal whitespace between words gets normalized to single spaces.

What's the difference between normalize-whitespace and basic trim?

Trim only removes leading/trailing spaces. Normalize-whitespace also collapses internal whitespace sequences (multiple spaces, mixed tabs/spaces) into single spaces throughout the text.

Can I normalize whitespace in large text blocks efficiently?

Yes, the tool handles large inputs efficiently. Send via REST API for batch processing or use MCP for real-time text cleanup in development workflows.

Try Normalize Whitespace Now

Get your free API key and start using Normalize Whitespace in seconds.

Get Free API Key