Empirical Formula Calculator
Turn percent composition or masses into the simplest whole-number formula, then into the molecular formula with a measured molar mass — with the working shown.
Enter the composition
Working
Show the Larzscript program that just ran
Run a calculation to see the exact program.
This is the real program the page sent to the Larzscript interpreter (compiled to WebAssembly) in your browser. The library it imports is the same code the automated tests check.
The method
- Treat each percentage (or mass) as grams of that element.
- Divide by the atomic weight to get moles of each.
- Divide all mole amounts by the smallest.
- If any result is not close to a whole number, multiply all by the same small integer (2, 3, 4 ...).
For iron and oxygen from 69.9% and 30.1%: Fe is 69.9 ÷ 55.845 = 1.2517 mol and O is 30.1 ÷ 15.999 = 1.8813 mol, a ratio of 1 : 1.5. Multiplying by 2 gives 2 : 3, so the formula is Fe2O3, iron(III) oxide. The calculator found multiplier 2.
From empirical to molecular formula
Benzene analyses as 92.3% C and 7.7% H, giving the empirical formula CH (mass 13.019 g/mol). Its measured molar mass is 78.11 g/mol, which is 6 × the empirical mass, so the molecular formula is C6H6. Aspirin (60.0% C, 4.48% H, 35.5% O, M = 180.16) works the same way: empirical C9H8O4, molecular C9H8O4.
What is verified
The solver is tested by round trip on 18 compounds: percentages computed from a known formula, rounded to four figures like a lab report, must return that formula in lowest terms (Fe₂O₃, Fe₃O₄, P₄O₁₀ → P₂O₅, aspirin C₉H₈O₄, caffeine C₈H₁₀N₄O₂ and others). Textbook examples are asserted as well.
Limits: results are only as good as the data. Ratios within 0.06 of a whole number are accepted; very large subscripts (above a multiplier of 12) are not searched.
Frequently asked questions
What is an empirical formula?
The simplest whole-number ratio of the atoms in a compound. Hydrogen peroxide is H₂O₂ but its empirical formula is HO; glucose is C₆H₁₂O₆ with empirical formula CH₂O.
How do you find an empirical formula from percent composition?
Assume 100 g so each percentage is a mass in grams, divide each mass by the atomic weight to get moles, divide all the mole amounts by the smallest, and, if needed, multiply by 2, 3 or 4 to clear fractions. For 40.0% C, 6.7% H, 53.3% O the mole ratios come out 1 : 2 : 1, so the formula is CH₂O.
What if the ratios are not whole numbers, like 1.5?
Multiply every ratio by the smallest integer that makes them all whole: 1 : 1.5 becomes 2 : 3. The calculator tries multipliers 1 to 12 and reports the one it used (titanium and oxygen from 59.9% / 40.1% give TiO2, multiplier 1). Ratios within 0.06 of a whole number count as whole, because lab percentages are rounded.
How do you get the molecular formula from the empirical formula?
Divide the measured molar mass by the empirical-formula mass and multiply the subscripts by that whole number. CH₂O weighs 30.03 g/mol, so a compound of molar mass 180.16 g/mol is 180.16 ÷ 30.03 = 6 formula units: C6H12O6, glucose. Enter the molar mass above to do this.
Can I use grams instead of percentages?
Yes: percent composition is just grams per 100 g, and the method is the same for any masses. 1 g of magnesium burning to give 1.658 g of oxide means 0.658 g of oxygen, which gives MgO.
Why does the calculator say the ratios are not close to whole numbers?
Usually because the data are incomplete (a fourth element is missing) or a percentage is mistyped. The maximum deviation from a whole number is shown so you can judge the fit.
Every number on this page is computed by the open-source larzscript-chem library (chemistry, elements, physconst, physmath), written in Larzscript, and checked against independent references in its test suite. How it is verified →