Converts numeric seconds into human-readable duration strings like "2h 15m 30s" or "1d 4h 22m". Access via MCP in Cursor or Claude Code, or REST at GET /v1/format/duration. Pass raw seconds (3661) and get formatted output ("1h 1m 1s"). Handles everything from milliseconds to years with precise, deterministic formatting.
curl "https://tinyfn.io/v1/format/duration" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/format/duration', {
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/duration',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
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"
}
}
}
}
Use the format_duration tool in your MCP-enabled editor with the seconds parameter. For example, 7323 seconds becomes "2h 2m 3s".
Returns compact format like "1d 2h 30m 45s" by default. Handles fractional seconds, supports units from milliseconds to years, and omits zero values for cleaner output.
Yes, supports any duration length. 172800 seconds becomes "2d", 90061 seconds becomes "1d 1h 1m 1s". No upper limit on input values.
Yes, accepts decimal inputs. 1.5 seconds becomes "1s 500ms", and 0.123 becomes "123ms". Precision is maintained in the formatted output.
Eliminates division/modulo math and edge cases. Instead of calculating hours = seconds // 3600, use this deterministic formatter for consistent, readable results across AI agents.
Get your free API key and start using Format Duration in seconds.
Get Free API Key