Skip to content
Tools.Town
290+ free online tools

Remove Extra Spaces API

Whitespace cleanup with surgical control — collapse spaces, trim lines, collapse newlines, remove blank lines, or strip ALL whitespace.

Category: Text Tools Endpoint: /v1/text/normalize-whitespace Method: POST Auth: API Key

Fast & Accurate

Get precise results instantly.

Easy Integration

Simple REST API with JSON response.

Developer Friendly

Clear docs and SDK examples.

Free to Start

5,000 free requests/month.

Endpoint

All requests should be made to the following endpoint:

POSThttps://api.tools.town/v1/text/normalize-whitespace

Authentication

This endpoint requires an API Key. Include your API key in the request header.

Authorization: Bearer YOUR_API_KEY
You can get your API key from your dashboard.

Request Parameters

Send a POST request with JSON body.

ParameterTypeRequiredDescriptionExample
textstringThe text parameter.Hello World
collapseSpacesbooleanThe collapseSpaces parameter.true
trimLinesbooleanThe trimLines parameter.true
collapseNewlinesbooleanThe collapseNewlines parameter.true
removeBlankLinesbooleanThe removeBlankLines parameter.true
stripAllWhitespacebooleanThe stripAllWhitespace parameter.true

Example Request

curl -X POST "https://api.tools.town/v1/text/normalize-whitespace" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello World"
  }'

Example Response 200 OK

application/json
{
  "success": true,
  "data": {
    "output": "string",
    "inputLength": "0",
    "outputLength": "0",
    "charsRemoved": "0"
  }
}

Error Codes

CodeMeaning
400Bad Request — missing or invalid parameter
401Unauthorized — API key missing or invalid
429Rate limit exceeded — free tier: 5,000 requests/month
500Internal Server Error — try again or contact support