Currency Format API: The Complete Guide to International Money Formatting

Need to display prices correctly for customers worldwide? This guide covers everything you need to know about formatting currency values for different locales via API, including currency symbols, positioning, and implementation examples in multiple languages.

What is Currency Formatting?

Currency formatting converts numeric values into properly formatted money strings with the correct currency symbol, decimal separator, grouping, and positioning based on locale preferences.

For example, 1234.56 USD formats as "$1,234.56" in the US, "1.234,56 $" in Germany, and "US$1,234.56" in many international contexts.

Locale Differences

Currency formatting varies significantly by region:

Symbol Position

US: $1,234.56 (symbol before). Germany: 1.234,56 Euro (symbol after). Some use ISO codes (USD 1,234.56).

Decimal Handling

Most currencies use 2 decimals, but Japanese Yen uses 0, and some currencies use 3 (Kuwaiti Dinar).

Negative Values

Various formats: -$100, ($100), $-100, $100- depending on region and context.

Important: Always use ISO 4217 currency codes (USD, EUR, GBP) for unambiguous identification across systems.

Using the Currency Format API

TinyFn provides a simple endpoint to format currency values:

API Request
GET https://api.tinyfn.io/v1/format/currency?value=1234.56¤cy=USD&locale=en-US
Headers: X-API-Key: your-api-key
Response
{
  "value": 1234.56,
  "currency": "USD",
  "locale": "en-US",
  "formatted": "$1,234.56",
  "symbol": "$",
  "isoCode": "USD"
}

Parameters

Parameter Type Description
value number The monetary value to format
currency string ISO 4217 currency code: USD, EUR, GBP, JPY, etc.
locale string Locale code: en-US, de-DE, ja-JP, etc. (default: en-US)
display string Display style: symbol, code, name, narrowSymbol (default: symbol)

Code Examples

JavaScript / Node.js

// Format USD for US locale
const response = await fetch(
  'https://api.tinyfn.io/v1/format/currency?value=1234.56¤cy=USD&locale=en-US',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const { formatted } = await response.json();
console.log(formatted); // $1,234.56

// Format EUR for German locale
const eurResponse = await fetch(
  'https://api.tinyfn.io/v1/format/currency?value=1234.56¤cy=EUR&locale=de-DE',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const { formatted: eurFormatted } = await eurResponse.json();
console.log(eurFormatted); // 1.234,56 Euro

Python

import requests

# Format USD for US locale
response = requests.get(
    'https://api.tinyfn.io/v1/format/currency',
    params={'value': 1234.56, 'currency': 'USD', 'locale': 'en-US'},
    headers={'X-API-Key': 'your-api-key'}
)
print(response.json()['formatted'])  # $1,234.56

# Format JPY for Japanese locale
response = requests.get(
    'https://api.tinyfn.io/v1/format/currency',
    params={'value': 1234, 'currency': 'JPY', 'locale': 'ja-JP'},
    headers={'X-API-Key': 'your-api-key'}
)
print(response.json()['formatted'])  # 円1,234

cURL

# Format USD
curl "https://api.tinyfn.io/v1/format/currency?value=1234.56¤cy=USD&locale=en-US" \
  -H "X-API-Key: your-api-key"

# Format GBP for UK locale
curl "https://api.tinyfn.io/v1/format/currency?value=1234.56¤cy=GBP&locale=en-GB" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • E-commerce: Display product prices in customer's preferred currency and format
  • Invoicing: Generate invoices with properly formatted amounts
  • Financial Reports: Create locale-appropriate financial statements
  • Multi-currency Apps: Support multiple currencies in payment flows
  • Price Comparison: Display converted prices consistently

Best Practices

  1. Store amounts as integers: Use cents/minor units to avoid floating-point issues
  2. Use ISO codes internally: Format only for display, not storage
  3. Respect currency decimals: JPY has 0 decimals, most have 2
  4. Test edge cases: Negative values, zero, very large amounts

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

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

See all formatting tools available via MCP in our Formatting MCP Tools for AI Agents guide.

Try the Currency Format API

Get your free API key and start formatting currency values in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key