Extends strings to a target length by adding padding characters on the left, right, or both sides. Use via MCP in Cursor or other AI tools, or call GET /v1/string/pad with text, length, and padding parameters. Perfect for formatting output, aligning data columns, or creating fixed-width strings. Handles Unicode characters correctly.
curl "https://tinyfn.io/v1/string/pad" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/pad', {
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/pad',
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"
}
}
}
}
Set the text parameter to your string, length to desired width, padChar to '0', and direction to 'left'. Example: padding '42' to length 5 gives '00042'.
The original string is returned unchanged. Padding only extends strings that are shorter than the specified length.
Yes, AI agents can call this tool to format numbers, align text columns, or create consistent string widths without generating incorrect padding logic.
Left (prepends padding), right (appends padding), and center (distributes padding on both sides). Center padding adds extra character to the right if total padding is odd.
Yes, it correctly handles Unicode strings and counts characters (not bytes) when determining padding length, ensuring proper alignment for international text.