About the Molar Mass Calculator
A free, instant calculator that computes the molar mass of any chemical formula with a full per-element breakdown, percent composition, and mass-to-moles conversion.
What it is
The Molar Mass Calculator computes the molar mass of any chemical compound from its formula. Type a formula and results appear instantly — no submit button, no page reload. It handles everything from simple molecules like H₂O and NaCl to complex compounds with nested parentheses like Al₂(SO₄)₃ and hydrates like CuSO₄·5H₂O.
Everything runs in your browser. Your formula is never sent to a server, stored, or logged. Close the tab and it is gone.
Key features
Formula parsing with parentheses
A stack-based parser correctly expands any level of nested parentheses and subscripts — Ca(OH)₂, Al₂(SO₄)₃, and more complex coordination compounds all parse accurately.
Hydrate notation
Accepts the middle dot (·) and plain period (.) as hydrate separators, with an optional multiplier for the water of crystallisation — CuSO₄·5H₂O, MgSO₄·7H₂O, etc.
Per-element breakdown
Shows each element's name, symbol, atom count, atomic weight, and contribution to the total molar mass — so you can trace exactly where every gram comes from.
Percent composition
Displays each element's percentage by mass with a proportional bar, making it easy to compare contributions at a glance — useful for identifying the dominant element in a compound.
Mass ↔ Moles conversion
Enter a mass in grams to get moles, or enter moles to get mass in grams. Both fields update instantly and recalculate automatically when the formula changes.
IUPAC atomic weights
Uses standard IUPAC atomic weights for all 118 elements, consistent with the values in chemistry textbooks and the NIST database. Results are reported to four decimal places.
Who it's for
Students
Verify homework answers, check percent composition for empirical formula problems, or confirm stoichiometric mole ratios before a calculation.
Teachers
Build worked examples live in class — change the formula and instantly see how the breakdown and percent composition change.
Lab professionals
Quickly convert between grams and moles for solution preparation, reagent weighing, and yield calculations — especially useful for hydrated salts.
Exam candidates
Use it to check answers during practice sessions. The per-element table shows the working step by step, confirming whether your manual calculation matches.
How the calculation works
The calculator normalises your input (replacing Unicode subscripts like ₂ with digits, and Unicode dots · with periods), then splits the formula at any hydrate separator. Each segment is parsed by a stack-based recursive algorithm: opening parentheses push a new accumulator onto the stack; closing parentheses pop it, multiply each element count by the subscript after the closing bracket, and merge the results into the parent level. Element symbols are matched case-sensitively so that, for example, Co (cobalt) and CO (carbon monoxide) are treated correctly.
Once the atom counts for every element are determined, the molar mass is computed as M = Σ (count × atomic weight) over all elements present. Percent composition for element i is % i = (count_i × AW_i / M) × 100. The mass-to-moles conversion uses n = m / M and the inverse m = n × M.
If any element symbol in the formula is not recognised, or if the parentheses are unbalanced, the tool shows a specific error message rather than returning a silent wrong answer.
Completely free
No sign-up, no rate limit, no premium tier. Calculate the molar mass of any compound instantly. If you find it useful, sharing it with a classmate or colleague is all we ask.