Cuts text strings to exact character limits with optional ellipsis indicators. Use via MCP in Cursor or call GET /v1/string/truncate with text and max length parameters. Returns "Hello wo..." for truncating "Hello world" to 8 chars. Handles Unicode properly unlike basic substring operations.
curl "https://tinyfn.io/v1/string/truncate" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/truncate', {
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/truncate',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
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"
}
}
}
}
Call the truncate function with your text and desired max_length. Set add_ellipsis=true to append '...' when text is cut, making truncated content visually obvious to users.
Yes, it counts actual characters rather than bytes. Emoji, accented letters, and multi-byte Unicode sequences each count as one character for accurate length calculations.
The original text is returned unchanged. No padding or modification occurs when input length is less than or equal to the specified maximum.
Absolutely. Set add_ellipsis=false or omit the parameter to get clean cuts without '...' suffixes. Useful for strict character limits in databases or APIs.
TinyFn's truncate handles Unicode properly, offers ellipsis options, and provides consistent behavior across languages. Basic substring can break on multi-byte characters or produce unexpected results.