About this tool
Type a chemical formula and this tool returns its molar mass and the mass percent contributed by each element. It understands element symbols with subscripts, nested groups such as Ca(OH)2 or K3[Fe(CN)6], and hydrate dot notation like CuSO4·5H2O or CuSO4.5H2O. All parsing and math happen in your browser.
A hand-written recursive parser reads the formula character by character — no eval and no formula-solving regular expressions — building a map of element to atom count. The molar mass is the sum of count times atomic mass for every element. For each element the mass percent is 100 × (count × atomic mass) / molar mass, and the individual percentages add up to 100%.
Unknown element symbols or unbalanced brackets are rejected as invalid input. Use it to check a synthesis yield, work out the metal content of an ore, or verify a molar mass before a titration.
Frequently asked questions
How is mass percent calculated?
For each element the tool computes 100 × (number of atoms × atomic mass) / molar mass. The molar mass is the total of every element's atom count multiplied by its atomic mass, so the percentages always sum to 100%.
Can it handle parentheses and hydrates?
Yes. Nested groups like Ca(OH)2 and Mg3(PO4)2 are expanded correctly, and hydrate notation such as CuSO4·5H2O — using a middle dot or a period — adds the water molecules to the total.
What happens with an invalid formula?
If you enter an unknown element symbol or mismatched brackets, the tool shows an invalid-input message instead of a wrong answer. Symbols are case sensitive, so use Co for cobalt and CO for carbon monoxide.
Does this run on a server?
No. The periodic-table masses and the formula parser are built into the page and run locally, so your formulas never leave your device.
More tools