x402AgentTools

๐Ÿท๏ธMargin & Markup Calculator

Calculate gross profit, profit margin (profit as % of price) and markup (profit as % of cost) from a unit cost and selling price โ€” the two numbers people constantly mix up.

Worked examples

Cost 60, price 100

GET /api/v1/finance/margin-calculator?cost=60&price=100

Result: 40% margin

SaaS seat: cost 4, price 29

GET /api/v1/finance/margin-calculator?cost=4&price=29

Result: 86.21% margin

Retail: cost 18, price 22

GET /api/v1/finance/margin-calculator?cost=18&price=22

Result: 18.18% margin

Machine API (x402)

$0.001 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol โ€” no accounts, no API keys.

GET /api/v1/finance/margin-calculator?cost=60&price=100 HTTP/1.1
Host: agenttools-hub.vercel.app

โ†’ 402 (payment required, instructions in headers)
โ†’ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "finance/margin-calculator",
  "input": {"cost":60,"price":100},
  "result": { "value": 40, "answer": "40% margin" }
}

Agent docs: /llms.txt ยท OpenAPI spec ยท integration guide

About this tool

Margin and markup describe the same profit from two directions: margin compares profit to the selling price, markup compares it to cost. A 25% margin is a 33.3% markup โ€” confusing the two silently underprices products.

margin % = (price โˆ’ cost) รท price ร— 100 ยท markup % = (price โˆ’ cost) รท cost ร— 100

Frequently asked questions

Why is markup always higher than margin?

Markup divides by the smaller number (cost), margin by the larger (price). 100% markup equals only a 50% margin.

What margin should I aim for?

It depends on the industry: grocery runs on 20โ€“30% margins, software often exceeds 80%. Compare within your sector, and make sure margin covers your fixed costs at your sales volume.

Related tools