If you build lab management software, educational tools, or scientific calculators, you need molarity. The formula is simple but the unit conversions trip everyone up.
The molarity formula
M = n / V
M = molarity (moles per liter, mol/L)
n = number of moles of solute
V = volume of solution in liters
To find moles from mass:
n = mass (g) / molar mass (g/mol)
Combined:
M = mass / (molar mass * volume)
Practical example
How much NaCl to make 500 mL of 0.9% saline (physiological saline)?
0.9% saline means 0.9 grams NaCl per 100 mL, or 9 g/L. The molar mass of NaCl is 58.44 g/mol.
M = 9 / 58.44 = 0.154 mol/L
For 500 mL:
mass = M * molar_mass * volume
mass = 0.154 * 58.44 * 0.5 = 4.5 g
Dissolve 4.5 grams of NaCl in enough water to make 500 mL total volume.
Dilution calculations
The dilution equation:
M1 * V1 = M2 * V2
M1 = initial molarity
V1 = initial volume
M2 = final molarity
V2 = final volume
To dilute 100 mL of 2M HCl to 0.5M:
2 * 100 = 0.5 * V2
V2 = 400 mL
Add water to bring the volume to 400 mL. (Always add acid to water, never water to acid.)
Unit conversion traps
The most common error is mixing up milliliters and liters. The formula uses liters. If your volume is in milliliters, divide by 1000 before plugging it in.
function molarity(massGrams, molarMass, volumeML) {
const moles = massGrams / molarMass;
const volumeL = volumeML / 1000;
return moles / volumeL;
}
For running molarity, dilution, and concentration calculations, I keep a calculator at zovo.one/free-tools/molarity-calculator. It handles unit conversions automatically and includes common molar masses for standard reagents.
I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.
Top comments (0)