String Utilities

Trim

Removes leading and trailing whitespace from text strings through GET /v1/string/trim. Essential for cleaning user input, parsing data, or preparing text for processing. Works with spaces, tabs, newlines, and other Unicode whitespace. MCP integration lets Claude and Cursor handle text cleanup deterministically without guesswork.

API Endpoint

GET /v1/string/trim

Code Examples

curl "https://tinyfn.io/v1/string/trim" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/trim', {
  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/trim',
    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

How do I trim whitespace from a string using the TinyFn API?

Send a GET request to /v1/string/trim with your text as a parameter. The API returns the string with all leading and trailing whitespace removed.

What types of whitespace does the trim function remove?

It removes all Unicode whitespace characters including spaces, tabs, newlines, carriage returns, and other whitespace defined by the Unicode standard.

Can I use TinyFn's trim function with MCP in my AI coding assistant?

Yes, the trim tool is available in Cursor, Claude Code, GitHub Copilot, Windsurf, Cline, OpenClaw, and Zed via MCP for reliable text cleaning without AI hallucination.

Does the trim function only remove whitespace from the beginning and end?

Correct, it only removes leading and trailing whitespace. Internal whitespace within the string remains unchanged.

What happens if I trim a string that has no leading or trailing whitespace?

The function returns the original string unchanged. It's safe to use on any text without checking for whitespace first.

Try Trim Now

Get your free API key and start using Trim in seconds.

Get Free API Key