Enter a chemical formula to find each element's percent by mass, the compound's molar mass, and a quick formula check.
How to use our Percent Composition Calculator
- Type the compound into Chemical formula using correct element symbols and subscripts, such as H2O, Ca(OH)2, or Al2(SO4)3.
- Choose Decimal places to control how many digits appear in the results.
- Click Calculate to see Molar mass, the Element breakdown, Percent total, and Formula check.
- Sanity-check the output: the Percent total should be about 100%, and each row in Element breakdown should match the atoms shown in your formula.
- If Formula check shows a warning or the numbers look off, recheck capitalization, parentheses, and whether you typed the full formula.

Definitions
Chemical formula: A short way to show which elements are in a compound and how many atoms of each are present.
Subscript: The small number after an element or group. It tells how many atoms are there, so H2 means 2 hydrogen atoms.
Molar mass: The mass of 1 mole of a substance, usually in g/mol. In this calculator, it is the total mass of all atoms in one formula unit added together [1].
Atomic mass: The average mass used for one element from the periodic table data, in g/mol [1].
Mass contribution: How much one element adds to the compound's total molar mass. It equals that element's atomic mass times its atom count.
Percent by mass: The percent of the compound's total mass that comes from one element [2].
Percent total: The sum of all element percentages. It should be about 100% for a valid formula.
Common mistakes and quick fixes
Mistake: Typing the wrong capitalization in Chemical formula , such as co instead of Co or CO.
Fix: Use valid element symbols with correct capitals. The first letter is uppercase, and the second letter, if any, is lowercase.
Mistake: Leaving out parentheses in Chemical formula for repeated groups, such as writing CaOH2 instead of Ca(OH)2.
Fix: Put repeating groups in parentheses so the atom counts in Element breakdown come out correctly.
Mistake: Entering words, sentences, or plain numbers into Chemical formula .
Fix: Enter only a real chemical formula, such as H2SO4 or C6H12O6.
Mistake: Expecting Percent total to be exactly 100.0000 after rounding each row.
Fix: A tiny difference is normal when values are rounded. Use more Decimal places if you want the displayed total to be closer to 100%.
Mistake: Trusting the table when Formula check says the formula is incomplete or invalid.
Fix: Fix the formula first, then recalculate. Do not use Molar mass or Element breakdown from an invalid formula.
Mistake: Trying hydrate dot notation like CuSO4.5H2O in Chemical formula when the parser does not support it.
Fix: Enter a supported standard formula only. If needed, rewrite the problem another way or use the anhydrous compound.
Limitations & Key Assumptions / Boundary Conditions
- The calculator only works for standard chemical formulas made from valid element symbols and whole-number subscripts.
- Parentheses must be matched correctly. An unfinished group or extra parenthesis will cause an error.
- Hydrate dot notation, equations, charges, and reaction symbols such as + or = are not supported in this build.
- The result depends on the embedded standard atomic weights, so tiny differences from a textbook or teacher's table can happen.
- Displayed percentages are rounded to the chosen number of decimal places, so Percent total may show a small difference from 100% even when the exact total is effectively 100.
- If a formula uses a format the parser does not support, the calculator should be treated as unable to evaluate that entry rather than as chemistry being wrong.
Methodology
How the calculator works
The calculator reads the Chemical formula, counts each element, looks up each element's atomic mass, and then builds the total compound mass from those parts.
mass_i = atomic_mass_i x atom_count_i
molar_mass_compound = sum(mass_i)
percent_i = (mass_i / molar_mass_compound) x 100
That means each row in Element breakdown is found in three steps: count atoms, find that element's mass contribution, then divide by the full Molar mass to get its percent by mass [2].
Worked mini-example
For H2O, the parser counts 2 H atoms and 1 O atom.
H mass = 1.008 x 2 = 2.016 g/mol
O mass = 15.999 x 1 = 15.999 g/mol
molar mass = 2.016 + 15.999 = 18.015 g/mol
H percent = (2.016 / 18.015) x 100 = 11.19%
O percent = (15.999 / 18.015) x 100 = 88.81%
percent total = 11.19 + 88.81 = 100.00%
This is why oxygen makes up most of water's mass even though water has more hydrogen atoms: one oxygen atom is much heavier than one hydrogen atom.
Formula check logic
The Formula check confirms that the entry is not blank, uses allowed characters, has known element symbols, and has matched parentheses. It also blocks unsupported formats such as hydrate dots, equations, or invalid text.
Assumptions used
The calculator uses standard atomic weights for elements [1]. Small differences from other tables can slightly change the last decimal place. Rounded display values can also make the shown Percent total differ a little from 100%, even when the unrounded math is complete.