String Utilities

Slug

Converts any text into URL-friendly slugs by removing special characters, normalizing spaces to hyphens, and lowercasing. Use via MCP in Cursor or Windsurf for consistent slug generation, or call GET /v1/string/slug directly. Perfect for creating clean URLs from article titles or user input. Handles Unicode normalization and prevents double-hyphens automatically.

API Endpoint

GET /v1/string/slug

Code Examples

curl "https://tinyfn.io/v1/string/slug" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/string/slug', {
  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/slug',
    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 does slug conversion handle special characters and Unicode?

Strips all non-alphanumeric characters except hyphens, normalizes Unicode to ASCII equivalents where possible, and converts spaces to single hyphens.

Can I use this MCP tool in Claude Code to generate slugs from dynamic content?

Yes, Claude Code can call the slug tool directly on any text input, making it ideal for generating consistent URL slugs from user-generated content or API responses.

What happens with multiple consecutive spaces or special characters?

Multiple spaces become a single hyphen, consecutive special characters are removed entirely, and the result is trimmed of leading/trailing hyphens.

Does the slug function preserve capitalization or always lowercase?

Always converts to lowercase for maximum URL compatibility and consistency across different systems and platforms.

How does this compare to JavaScript's encodeURIComponent for URL safety?

Creates human-readable slugs rather than percent-encoded strings - 'Hello World!' becomes 'hello-world' instead of 'Hello%20World%21'.

Try Slug Now

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

Get Free API Key