Formatting Utilities

Format Credit Card

Transforms raw credit card numbers into standardized, readable formats with proper spacing. Access via MCP in Cursor or Windsurf, or call GET /v1/format/credit-card directly. Input "4111111111111111" returns "4111 1111 1111 1111". Handles all major card types with their specific grouping patterns.

API Endpoint

GET /v1/format/credit-card

Code Examples

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

response = requests.get('https://tinyfn.io/v1/format/credit-card',
    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 formatting tools:

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

Learn more about MCP setup →

FAQ

How do I format a credit card number with spaces using MCP?

Use the format_credit_card tool in your MCP-enabled editor with the card number as input. It automatically detects the card type and applies the correct spacing pattern.

What credit card types does the formatter support?

Supports Visa, Mastercard, American Express, Discover, and other major card types. Each gets its standard grouping: 4-4-4-4 for most cards, 4-6-5 for Amex.

Does the credit card formatter validate card numbers?

No, it only formats the spacing. It doesn't validate checksums, expiration dates, or whether the number is real. Use a separate validation tool for security checks.

Can I format partial or invalid credit card numbers?

Yes, it formats any numeric input with appropriate spacing based on length and detected pattern. Incomplete numbers get formatted as far as possible.

What's the REST API endpoint for credit card formatting?

GET /v1/format/credit-card with the card number as a parameter. Returns the formatted number with proper spacing for display purposes.

Try Format Credit Card Now

Get your free API key and start using Format Credit Card in seconds.

Get Free API Key