String Utilities

Pad

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.

API Endpoint

GET /v1/string/pad

Code Examples

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)

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 pad a string to the left with zeros?

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'.

What happens if the input string is already longer than the target length?

The original string is returned unchanged. Padding only extends strings that are shorter than the specified length.

Can I use this MCP tool to format data in Claude Code or Cursor?

Yes, AI agents can call this tool to format numbers, align text columns, or create consistent string widths without generating incorrect padding logic.

What padding directions are supported?

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.

Does string padding work with multi-byte Unicode characters?

Yes, it correctly handles Unicode strings and counts characters (not bytes) when determining padding length, ensuring proper alignment for international text.

Try Pad Now

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

Get Free API Key