What this calculator does
Work out a compound's chemical formula from how much of each element it contains. An empirical formula gives the simplest whole-number ratio of atoms in a compound. Chemists find it from a lab test that reports how much of each element a sample holds. The result comes either as mass percentages or as grams. Glucose, for example, tests as about 40% carbon, 6.7% hydrogen and 53.3% oxygen. That works out to the ratio CH₂O.
This calculator does the conversion step by step. First it turns grams into moles (a way of counting atoms) using standard atomic weights. Then it divides by the smallest amount. When the ratios come out as halves, thirds or quarters, it multiplies them up. If you also know the molar mass (the mass of one mole of the compound), it scales the empirical formula up to the molecular formula.
Where it's used
Why this math matters outside the classroom:
- Chemistry class. Students turn 40.0% C, 6.71% H and 53.29% O into CH₂O and then glucose, C₆H₁₂O₆.
- Combustion analysis. A lab converts the grams of carbon and hydrogen found from burning a sample into a C:H mole ratio.
- Minerals. A geology student finds an iron oxide with 69.94% iron has the formula Fe₂O₃.
- Quality checks. An analyst confirms a synthesized product's formula by comparing measured percentages with the expected ratio.
- Fertilizer chemistry. Students identify phosphorus pentoxide from 43.64% P and 56.36% O as P₂O₅.
How to use it
- Choose whether your data are mass percentages or masses in grams.
- Pick each element and enter its amount. Use the optional third and fourth slots for compounds with more elements.
- If you know it, enter the compound's molar mass to get the molecular formula.
- Read the empirical formula and check the mole ratios in the working.
What the inputs mean
- Amounts are
- Percentages are treated as grams in a 100 g sample, so both options use the same math. Percentages should add up to about 100.
- Amount of element 1
- A mass percent, or a mass in grams, matching the choice above.
- Molar mass of the compound (optional)
- The molar mass must be close to a whole-number multiple of the empirical formula mass. If it isn't, the calculator tells you instead of guessing.
Formula and method
moles of each element = mass ÷ atomic weight ratio = moles ÷ smallest moles multiply all ratios by 2, 3, 4 … until each is within 0.1 of a whole number molecular formula = empirical formula × (molar mass ÷ empirical formula mass)
A formula counts atoms. Moles count atoms in handy bundles, the way a dozen counts eggs. So the mole amounts of the elements are in the same ratio as their atoms. An element's atomic weight is how many grams one mole of it weighs. Dividing every mole amount by the smallest one makes that element 1.
Measured data never give perfectly whole numbers. A ratio such as 1.98 rounds to 2. But 1.5, 1.33 or 1.25 are a sign that every ratio must first be multiplied by 2, 3 or 4. The calculator tries multipliers up to 8. It uses the smallest one that brings every ratio within 0.1 of a whole number.
The empirical formula mass is the mass of one unit of the empirical formula, found by adding up its atomic weights.
Worked example
A sugar is 40.00% carbon, 6.71% hydrogen and 53.29% oxygen by mass, and its molar mass is 180.16 g/mol. What are its empirical and molecular formulas?
- Take 100 g: 40 g C, 6.71 g H and 53.29 g O.
- Moles: C 40 ÷ 12.011 = 3.330281; H 6.71 ÷ 1.008 = 6.656746; O 53.29 ÷ 15.999 = 3.330833.
- Divide by the smallest (3.330281): C 1 : H 1.999 : O 1. That rounds to 1 : 2 : 1, so CH₂O.
- Empirical formula mass: 12.011 + 2 × 1.008 + 15.999 = 30.026 g/mol. Then 180.16 ÷ 30.026 = 6.0001, about 6.
Result: The empirical formula is CH₂O and the molecular formula is C₆H₁₂O₆, glucose.
Understanding the result
Different compounds can share an empirical formula. Formaldehyde (CH₂O), acetic acid (C₂H₄O₂) and glucose (C₆H₁₂O₆) all reduce to CH₂O. The molar mass tells them apart.
The calculator may warn that the ratios aren't close to whole numbers. If so, the data may be rounded too much, or the sample may not be pure. An element may also be missing. Often that's oxygen, which is found by subtracting the others.
Assumptions and limitations
- The amounts are for a single pure compound, and every element in it is listed.
- Standard atomic weights (the IUPAC abridged values, the shortened official list) apply.
- Elements are written in the order you enter them. They aren't sorted into Hill order (carbon, then hydrogen, then the rest A to Z) or the usual order for ionic compounds.
- Structure, isomers (compounds with the same atoms arranged differently) and charges can't be found from composition alone.
- Very rough data may fit a wrong formula. Check that the result makes chemical sense.
Frequently asked questions
What is the difference between an empirical and a molecular formula?
The empirical formula is the simplest ratio of atoms. The molecular formula is the actual number of each atom in one molecule. Benzene's molecular formula is C₆H₆, but its empirical formula is CH.
What do I do with a ratio like 1.5?
Multiply every ratio by 2, which gives whole numbers. For about 1.33 or 1.67, multiply by 3. For about 1.25 or 1.75, multiply by 4. Iron oxide with Fe 1 : O 1.5 becomes Fe₂O₃.
What if the percentages don't add up to 100?
Small gaps come from rounding. A large gap usually means an element wasn't measured. Oxygen is often found by subtracting the others from 100%.
Can I use masses instead of percentages?
Yes. Masses in grams work the same way, because only the ratio of moles matters. Choose 'Masses in grams' and enter each element's mass.
How this calculator is checked
Method: Mole-ratio method for empirical formulas; IUPAC abridged standard atomic weights (src/lib/chem/elements.ts). The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Empirical Formula Calculator on your own website or blog for free. Paste this code where you want it to appear: