Volume to density calculator
Divide a sample's mass by the volume it occupies and get its density: 10 kg in 2 m³ gives 5 kg/m³, and grams over cubic centimetres give g/cm³. Made for lab checks, homework and receiving inspection. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Mass
- 10
- Volume
- 2
- Density
- 5
Density is mass per unit volume, and the everyday physics step is one-way: you already weighed a sample and you already know the space it occupies, so the remaining unknown is density itself. This volume-to-density calculator accepts those two measured numbers, divides mass by volume, and returns density in coherent units—kilograms per cubic metre when mass is kilograms and volume is cubic metres, or grams per cubic centimetre when you send grams and cubic centimetres. Volume must be strictly positive.
What volume-to-density means and why volume must be positive
Density of a uniform body is defined as mass divided by the volume that body occupies. In a physics laboratory that definition is almost never an algebraic rearrange among three unknowns: you weigh the sample on a balance, you measure or compute the volume from liquid displacement, a pycnometer, calipers plus a geometric formula, or a stated container fill, and you want density as the quotient. Send mass m and volume V; receive density rho equals m over V.
SI coherent units are kilograms, cubic metres, and kilograms per cubic metre, but the engine never converts millilitres to cubic metres or grams to kilograms. If you send grams and cubic centimetres, the density is grams per cubic centimetre, which for many student tables equals the specific gravity relative to water near four degrees Celsius. Volume must be strictly greater than zero because a vanishing or inverted sample volume does not define a physical density.
Where it helps and which units to use
Physics classrooms, materials labs, and quality teams use a volume-to-density calculator whenever mass and volume are already known and the remaining question is whether the sample matches a published material. Students check homework that states a metal slug of given grams occupying a given number of millilitres. Metrology benches weigh a pycnometer fill and divide by the known flask volume.
Receiving inspection weighs a polymer pellet batch and divides by a measured hopper volume to flag moisture uptake or a wrong resin. Tutoring platforms and exam generators need a deterministic oracle that rejects a zero or negative volume instead of silently returning Infinity. Failed validation does not consume balance.
Convert millilitres and grams before you call if your instruments report those units. Keep requests small, pin the rounded density in tests, and you get reproducible values for homework, receiving inspection, and edge workers without standing up a computer-algebra system of your own.
What you can do with it
Lab mass and displacement volume
Weigh a sample, measure occupied volume by displacement or pycnometer, and convert the pair into density in coherent units for a material check.
Receiving inspection of bulk solids
Divide a weighed hopper or bag mass by a measured fill volume to flag the wrong resin, moisture uptake, or mixed stock against a published density.
FAQ
How do I compute density from mass and volume?
Send two finite numbers: mass (non-negative) and volume (strictly positive).
What happens if volume is zero or negative?
Density is undefined for a vanishing sample volume, and a negative volume is not a physical occupied volume, so those requests are not billed.
What units should I use for mass and volume?
Use any coherent pair. Kilograms and cubic metres yield kg/m³; grams and cubic centimetres yield g/cm³. The engine does not convert units for you.
Does this calculator also solve for mass or volume?
No. This is the one-way physics step from measured mass and volume to density. It does not rearrange ρ = m/V for the other two unknowns.
How can a density check reveal the wrong material?
Compare the result with the published density of the material you expect. Receiving inspection, for example, weighs a batch of polymer pellets, divides by the measured volume and flags moisture uptake or a wrong resin.
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/phys/volume-to-density \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mass":10,"volume":2}'const res = await fetch("https://api.kit.forhosting.com/phys/volume-to-density", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mass": 10,
"volume": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/phys/volume-to-density",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mass": 10,
"volume": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/phys/volume-to-density", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mass":10,"volume":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mass":10,"volume":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/phys/volume-to-density", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"mass": 10,
"volume": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "phys.volume_to_density",
"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.
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
A zero volume or a negative volume is not a physical sample, so the task fails with invalid_input instead of Infinity or a signed nonsense result.
What volume-to-density means and why volume must be positive
This endpoint is that one-way step. Zero volume would make the quotient undefined and would yield Infinity in IEEE floating point, which this product refuses to publish as a successful result. A negative volume is equally unphysical for a laboratory sample: it is not a signed flux or a change in volume, it is a bad measurement or a sign error, and the task fails with invalid_input. Identical numeric inputs always produce identical JSON because the path is pure division with no network, no language model, no random seed, and no wall clock.
Input contract, response shape, and zero or negative volume
Volume is the occupied volume and must be strictly positive. Extremely large magnitudes that would overflow to Infinity are rejected. This calculator does not solve for mass from density and volume, and it does not solve for volume from mass and density: those rearranges belong to a different workflow. It also does not convert units, compute cylinder or sphere volume from dimensions, or look up material tables. Example: mass ten and volume two yields density five in coherent units. Example: mass one and volume three yields one third, rounded stably. Failed validation is not billed. POST a JSON body with two required finite numbers: mass and volume. Mass is the measured mass of the sample and may be zero; a negative mass, a non-finite value, or a missing field fails with invalid_input naming the field. Zero volume and negative volume both fail with invalid_input and a message that volume must be positive because zero or negative volume is invalid for rho equals m over V. Each field may arrive as a JSON number or as a numeric string; empty strings are treated as missing. Aliases are accepted so existing lab payloads map without renaming: m and mass_kg for mass; V, vol, and volume_m3 for volume. On success the body echoes mass and volume, then density as mass divided by volume, plus a formula string restating rho equals m slash V and method equal to volume_to_density so clients can branch without sniffing shapes. Pair the response with your own unit labels if you need a printed certificate; this endpoint returns the numbers, not a formatted report.
Where a volume-to-density API earns its keep, units, and price
Do not send a geometric diameter and expect this endpoint to form a cylinder volume—that is a different calculator.
Integration use cases
Classroom density homework
Students submit mass and volume and verify ρ = m/V, including a clear invalid_input error when volume is zero or negative.
Technical questions
What does the volume to density calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.