
Unit price
Calculate a price per kilogram, liter or item and compare two offers.
Your inputs stay in your browser.
Method and assumptions
Method version 1.0.0 · Updated
Calculate a unit price
Formula: Unit price = price / quantity in kg, L or items
The result is per kilogram for g/kg, per liter for mL/L, or per item. Example: 3 for 500 g → 6 per kg. Quantity must be strictly positive. No mass/volume conversion or additional fees.
- price
- Pack price
- quantity
- Pack quantity
- unit
- Quantity unit
- precision
- Money decimal places
Compare two offers
Formula: Compare price A / quantity A and price B / quantity B
Compare the same currency and quantity type. g and kg are compatible, as are mL and L; mass, volume and items cannot be mixed. Comparison uses exact prices before display rounding: two identical displayed prices can still have a cheaper offer.
- priceA
- Offer A price
- quantityA
- Quantity A
- unitA
- Unit A
- priceB
- Offer B price
- quantityB
- Quantity B
- unitB
- Unit B
- precision
- Money decimal places
All amounts use the same currency, without conversion. Choose 0, 2 or 3 decimal places for your needs. Rounded to nearest, ties up.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const price = 4.50, quantity = 1.5;
console.log(price / quantity); // 3 per unitTypeScript
const price = 4.50, quantity = 1.5;
const unitPrice: number = price / quantity;
console.log(unitPrice); // 3Python
price, quantity = 4.50, 1.5
print(price / quantity) # 3.0 per unitJava
double price = 4.50, quantity = 1.5;
System.out.println(price / quantity); // 3.0 per unitC#
decimal price = 4.50m, quantity = 1.5m;
Console.WriteLine(price / quantity); // 3.0 per unit