GenerateRandomSearch

Molar Mass Calculator

A formula tells you how many atoms of each element are in a compound; the molar mass tells you what they weigh together, and the percentage composition tells you which element dominates that weight — which is often not the one with the most atoms. Water has twice as many hydrogens as oxygens and is nearly ninety percent oxygen by mass. This computes all three and adds the parts back up.

What this generator does

Parses the formula into element counts, multiplies each by its atomic mass, and totals them. Each element's share of the total is computed, and the parts are added back up against the whole before display.

How to use this tool

  1. Enter a formula, using brackets if you need them.
  2. Read the molar mass in grams per mole.
  3. Look at the share column: mass share and atom count are different things.
  4. Try Ca(OH)2 to see bracketed groups handled properly.

Understanding the controls

Formula
Element symbols with counts, and brackets where a group repeats. Ca(OH)2 and CaO2H2 give the same mass, but the first is what a chemist would write.

Common use cases

  • Working out the molar mass of a compound for a calculation
  • Finding the percentage composition by mass
  • Checking a molar mass answer against an independent calculation
  • Teaching why mass share differs from atom count
  • Producing molar masses for a chemistry worksheet

How this generator works

The formula is parsed character by character into a count per element, with brackets handled by keeping a stack so a group's multiplier applies to everything inside it. Each element contributes its atomic mass times its count, and the total is the sum. Before display the parts are re-totalled against the stated mass, every count is checked back against the formula, and the percentages are added up and confirmed to come to a hundred.

Randomness and fairness

Nothing here is random. A formula has exactly one molar mass.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Atomic masses are standard averages over natural isotope abundances, so an isotopically enriched sample differs.
  • The element list covers those met in school chemistry, so a formula using a lanthanide or a synthetic element will not resolve.
  • Hydrates written with a dot, like CuSO4·5H2O, need the water added into the formula by hand.
  • Charges on ions are not parsed, so a formula written with a superscript charge will be rejected.

Privacy and your data

The calculation runs in your browser and the formula you enter is never transmitted, stored or included in analytics.