URL/Slug Utilities

Filename Safe

Converts any string into a filesystem-safe filename by removing or replacing problematic characters. Use via MCP in Cursor/Windsurf or GET /v1/slug/filename-safe with your text. Perfect for AI agents generating files from user input — "My Project #1.doc" becomes "My-Project-1.doc" while preserving readability and avoiding OS conflicts.

API Endpoint

GET /v1/slug/filename-safe

Code Examples

curl "https://tinyfn.io/v1/slug/filename-safe" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/slug/filename-safe', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/slug/filename-safe',
    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 url/slug tools:

{
  "mcpServers": {
    "tinyfn-slug": {
      "url": "https://tinyfn.io/mcp/slug",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What characters does filename-safe remove or replace?

Removes illegal characters like <, >, :, ", |, ?, *, / and \ while replacing spaces with hyphens. Also handles reserved names like CON, PRN, AUX on Windows.

How can MCP agents use this for file generation workflows?

AI agents in Cursor or Cline can sanitize user-provided titles before creating files, ensuring cross-platform compatibility without manual intervention.

Does it preserve the original filename length and extension?

Maintains reasonable length while preserving file extensions. Long names get truncated intelligently to stay under filesystem limits.

Can I use this for batch processing multiple filenames?

Each API call processes one string. For batch operations, make multiple requests or integrate into your processing loop.

What's the difference between this and regular slug generation?

Filename-safe preserves more characters and file extensions, while slugs are optimized for URLs with stricter character limitations.

Try Filename Safe Now

Get your free API key and start using Filename Safe in seconds.

Get Free API Key