Price per unit calculator
A 2 lb bag of coffee at 13.99 beats a 12 oz bag at 6.49 once both are converted to ounces, because it holds 32 oz. Enter each package's price, size and unit to find the best value. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Target unit
- Oz
- Dimension
- weight
- Quantity
- 2
- Best index
- 1
- Best indexes
- 1
The price per unit calculator makes differently sized packages directly comparable. Enter each package price, quantity, and unit, then choose a reporting unit or let the calculator use the first product’s unit. It converts compatible weight, volume, or count measurements before dividing price by quantity, so a two-pound bag can be compared fairly with a twelve-ounce bag. The result lists every normalized quantity and unit price, identifies the cheapest option, and handles exact ties. Calculations are deterministic and use no network calls, changing rates, randomness, or stored data.
Compare package prices on a common basis
Sticker price alone rarely tells you which package offers better value. A larger bottle normally costs more in total, yet it may cost less for every milliliter. This calculator creates the common basis needed for a fair comparison.
For each product, provide the full package price, the numeric quantity shown on the label, and its unit. Supported weight units are grams, kilograms, ounces, and pounds. Supported volume units are milliliters, liters, US fluid ounces, and US gallons.
Counted products can use individual count or dozens. The calculator converts every package to one target unit, divides its price by that converted quantity, and marks the lowest result as the best value. If no target is supplied, the first product’s package unit becomes the target, which makes a quick two-item comparison convenient.
You can also calculate one product when you only need its unit cost. Products in one request must describe the same measurement dimension: weight cannot be compared directly with volume, and neither can be compared with count. This restriction prevents a numerical result that looks precise but has no useful physical meaning.
The output retains the original package quantity and unit alongside the normalized quantity, making the arithmetic easy to review instead of hiding the conversion step.
Enter clean prices, quantities, and units
Use plain numbers for price and quantity. Price may be zero, which is useful for a free promotional package, but it cannot be negative. Quantity must be greater than zero because division by zero has no defined unit price and negative package contents do not fit this model.
Each product can include a name, and unnamed rows receive a stable Product 1, Product 2, and similar label. Conversion uses fixed physical factors: one kilogram is one thousand grams, one pound is 453.59237 grams, one liter is one thousand milliliters, and one US gallon is 3785.411784 milliliters. The calculator does not convert currencies, apply sales tax, subtract coupons, account for membership fees, or estimate product quality.
Include those adjustments in each package price before calculation when they affect your actual checkout cost. Keeping the input narrow makes the result predictable for both interactive use and automated validation.
What you can do with it
Grocery package comparison
Compare bags, bottles, or multipacks with different sizes and choose the lowest cost in one shared unit.
Procurement catalog review
Normalize supplier pack prices before approving a SKU or highlighting a lower-cost purchasing option.
Ecommerce unit-price display
Generate consistent price-per-weight, price-per-volume, or price-per-count fields for product listings and tests.
FAQ
How is price per unit calculated?
The package quantity is converted to the target unit, then the package price is divided by that normalized quantity.
Can I compare pounds with ounces or liters with milliliters?
Yes. Compatible units within weight or volume are converted automatically before comparison.
Can I compare a weight with a volume, like grams with milliliters?
No. All products in one comparison must use the same kind of measure: weight, volume or count. This prevents a result that looks precise but has no useful physical meaning.
What happens if two packages cost the same per unit?
The calculator recognizes exact ties and marks every package that shares the lowest unit price as the best value, not only the first one on the list.
Does it include sales tax, coupons or membership fees?
No. It also does not convert currencies or judge quality. If those adjustments matter, build them into each package price before you calculate.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/finance/price-per-unit \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"products":[{"name":"Small coffee","price":6.49,"quantity":12,"unit":"oz"},{"name":"Large coffee","price":13.99,"quantity":2,"unit":"lb"}]}'const res = await fetch("https://api.kit.forhosting.com/finance/price-per-unit", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"products": [
{
"name": "Small coffee",
"price": 6.49,
"quantity": 12,
"unit": "oz"
},
{
"name": "Large coffee",
"price": 13.99,
"quantity": 2,
"unit": "lb"
}
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/finance/price-per-unit",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"products": [
{
"name": "Small coffee",
"price": 6.49,
"quantity": 12,
"unit": "oz"
},
{
"name": "Large coffee",
"price": 13.99,
"quantity": 2,
"unit": "lb"
}
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/finance/price-per-unit", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"products":[{"name":"Small coffee","price":6.49,"quantity":12,"unit":"oz"},{"name":"Large coffee","price":13.99,"quantity":2,"unit":"lb"}]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"products":[{"name":"Small coffee","price":6.49,"quantity":12,"unit":"oz"},{"name":"Large coffee","price":13.99,"quantity":2,"unit":"lb"}]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/finance/price-per-unit", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"products": [
{
"name": "Small coffee",
"price": 6.49,
"quantity": 12,
"unit": "oz"
},
{
"name": "Large coffee",
"price": 13.99,
"quantity": 2,
"unit": "lb"
}
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "finance.price_per_unit",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
min_products | 1 |
max_products | 50 |
max_abs | 1000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Run it in the browser for an occasional shopping decision or call the API for $0.002 when automating catalog, purchasing, or budgeting workflows.
Enter clean prices, quantities, and units
Currency symbols, commas, and localized numeric text should be removed before calling the API; the contract accepts finite JSON numbers so accidental formatting cannot be silently misread. Choose target_unit when you want a familiar shelf convention, such as price per 1000 grams expressed through kilograms, price per fluid ounce, or price per individual item even when a carton is labeled in dozens. Invalid rows return an invalid_input error rather than an invented value.
Read the result and use it in decisions
Every successful response reports the shared measurement dimension, target unit, number of products, and a products array. Treat the result as one part of a purchase decision: a lower unit price may not be better if excess product expires, storage is limited, or quality differs. Also confirm that the shelf quantity represents comparable usable contents; drained weight, concentrated servings, and multipack subunits sometimes require adjusting quantity first. Each product record includes its original price, quantity, and unit; its quantity converted to the target unit; its calculated price_per_unit; and an is_best_value flag. best_index points to the first cheapest row, while best_indexes includes every cheapest row when two or more packages tie after stable rounding. best_name and best_price_per_unit provide convenient summary fields for a user interface or purchasing rule. Because the calculation uses fixed conversion constants and rounds output consistently, identical JSON input produces identical JSON output in the browser and through the API. That makes the capability useful in grocery comparison tools, procurement approval flows, inventory imports, educational exercises, and tests for ecommerce displays. API requests cost $0.002 per successful calculation. For auditing, recompute package price divided by normalized_quantity and confirm it agrees with price_per_unit.
Technical questions
Can I compare weight with volume?
No. Weight, volume, and count are separate dimensions, and mixing them returns invalid_input because the result would not be meaningful.
What happens when two products have the same unit price?
Every tied product is marked is_best_value, best_indexes lists all of them, and best_index identifies the first tied row.
What does the API calculation cost?
A successful API request costs $0.002. The browser calculator runs the same deterministic calculation locally.