In physics and chemistry, volume, mass, and density are interconnected properties of matter. If you know the mass of an object and the density of the material it is made of, you can easily calculate its volume using a simple mathematical formula.
The Formula
Volume (V) = Mass (m) ÷ Density (ρ)
Definitions
Mass (m): The amount of matter in an object, typically measured in kilograms (kg) or grams (g).
Density (ρ): The mass per unit volume of a substance. It describes how "compact" a substance is. Common units include kg/m³ or g/cm³.
Volume (V): The amount of three-dimensional space an object occupies.
Step-by-Step Calculation Example
Suppose you have a block of pure gold with a mass of 5,000 grams (5 kg). You know the density of gold is 19.32 g/cm³.
Identify the mass: m = 5000 g
Identify the density: ρ = 19.32 g/cm³
Apply the formula: V = 5000 / 19.32
Final Result: V ≈ 258.8 cm³
Common Densities Table
Substance
Density (kg/m³)
Water (at 4°C)
1,000
Steel
7,850
Aluminum
2,700
Air (at sea level)
1.225
function calculateVolume() {
var mass = parseFloat(document.getElementById("massInput").value);
var massUnit = document.getElementById("massUnit").value;
var density = parseFloat(document.getElementById("densityInput").value);
var densityUnit = document.getElementById("densityUnit").value;
var resultUnit = document.getElementById("resultUnit").value;
var resultDisplay = document.getElementById("volumeResultContainer");
var valueOutput = document.getElementById("volumeValue");
var unitOutput = document.getElementById("volumeUnitLabel");
var formulaStep = document.getElementById("formulaStep");
if (isNaN(mass) || isNaN(density) || density <= 0 || mass < 0) {
alert("Please enter valid positive numbers. Density must be greater than zero.");
return;
}
// Convert Mass to base unit (kg)
var massInKg;
if (massUnit === "kg") {
massInKg = mass;
} else if (massUnit === "g") {
massInKg = mass / 1000;
} else if (massUnit === "mg") {
massInKg = mass / 1000000;
} else if (massUnit === "lb") {
massInKg = mass * 0.453592;
}
// Convert Density to base unit (kg/m3)
var densityInKgM3;
if (densityUnit === "kg/m3") {
densityInKgM3 = density;
} else if (densityUnit === "g/cm3") {
densityInKgM3 = density * 1000;
} else if (densityUnit === "lb/ft3") {
densityInKgM3 = density * 16.0185;
}
// Calculate Volume in base unit (m3)
var volumeInM3 = massInKg / densityInKgM3;
// Convert Volume to selected output unit
var finalVolume;
var unitLabel;
if (resultUnit === "m3") {
finalVolume = volumeInM3;
unitLabel = "m³";
} else if (resultUnit === "cm3") {
finalVolume = volumeInM3 * 1000000;
unitLabel = "cm³";
} else if (resultUnit === "L") {
finalVolume = volumeInM3 * 1000;
unitLabel = "L";
} else if (resultUnit === "ml") {
finalVolume = volumeInM3 * 1000000;
unitLabel = "ml";
} else if (resultUnit === "ft3") {
finalVolume = volumeInM3 * 35.3147;
unitLabel = "ft³";
} else if (resultUnit === "in3") {
finalVolume = volumeInM3 * 61023.7;
unitLabel = "in³";
}
// Formatting for display
var displayVal;
if (finalVolume 10000) {
displayVal = finalVolume.toLocaleString(undefined, {maximumFractionDigits: 2});
} else {
displayVal = parseFloat(finalVolume.toFixed(6));
}
valueOutput.innerHTML = displayVal;
unitOutput.innerHTML = unitLabel;
formulaStep.innerHTML = "Calculation: " + mass + " " + massUnit + " / " + density + " " + densityUnit + " = " + displayVal + " " + unitLabel;
resultDisplay.style.display = "block";
}