Calculate profit margins instantly with precise financial math. Access via MCP in Cursor or Claude Code, or through REST API at `/v1/finance/margin`. Input revenue and cost to get gross margin percentage — essential for pricing decisions, financial analysis, and business planning. Returns standardized decimal format for consistent calculations.
curl "https://tinyfn.io/v1/finance/margin" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/finance/margin', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/finance/margin',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's finance tools:
{
"mcpServers": {
"tinyfn-finance": {
"url": "https://tinyfn.io/mcp/finance",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Provide revenue and cost values to get the margin percentage. Formula is (revenue - cost) / revenue × 100. Returns precise decimal results for financial accuracy.
Margin calculates profit as percentage of revenue, while markup calculates profit as percentage of cost. This tool computes margin — more common in financial reporting.
Yes, integrate with Cursor, Windsurf, or other MCP-enabled editors for automated margin calculations in spreadsheets, reports, and pricing models.
Handles negative margins (losses) correctly. Zero revenue returns undefined/error to prevent division by zero in financial calculations.
Returns full precision decimal values. You control rounding based on your accounting standards or reporting requirements.
Get your free API key and start using Calculate Margin in seconds.
Get Free API Key