Conversion Utilities

Kilometers To Miles

Converts kilometers to miles with precise calculation using the standard conversion factor (1 km = 0.621371 miles). Access via MCP in Cursor or Windsurf for AI-assisted distance calculations, or call GET /v1/convert/length/km-to-mi directly. Returns exact decimal results — no rounding or approximation errors that plague manual calculations.

API Endpoint

GET /v1/convert/length/km-to-mi

Code Examples

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

response = requests.get('https://tinyfn.io/v1/convert/length/km-to-mi',
    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 conversion tools:

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

Learn more about MCP setup →

FAQ

How accurate is the kilometer to miles conversion?

Uses the exact conversion factor of 0.621371192 miles per kilometer, providing precision to multiple decimal places without rounding errors.

Can I convert fractional kilometers like 2.5 km?

Yes, accepts any numeric input including decimals. For example, 2.5 km converts to exactly 1.553428 miles.

How do I use this with MCP in my AI coding assistant?

Enable TinyFn's MCP server in your editor, then ask your AI assistant to convert distances. It will call the tool automatically for accurate results.

What format does the API return?

Returns a JSON response with the converted miles value as a number, maintaining full precision of the calculation.

Why use this instead of multiplying by 0.621371 myself?

Eliminates floating-point precision errors and ensures consistent results across different programming languages and platforms.

Try Kilometers To Miles Now

Get your free API key and start using Kilometers To Miles in seconds.

Get Free API Key