Molar mass calculator

Enter a chemical formula (H2O, C6H12O6, Ca(OH)2...) to calculate its total molar mass from the atomic masses of each element, with a per-element breakdown of the calculation.

Examples:

How it works

The formula is parsed character by character: each element symbol (an uppercase letter optionally followed by a lowercase one) is paired with the number that follows it, and groups in parentheses are multiplied by the number right after the closing parenthesis, as in Ca(OH)2 where the OH group is counted twice.

How do I write a formula with nested parentheses?

The tool accepts standard parentheses, for example Mg(NO3)2 for magnesium nitrate: the NO3 group is multiplied by 2, giving 1 magnesium, 2 nitrogen and 6 oxygen atoms in total, each weighted by its own atomic mass.

What if an element isn't recognized?

Check the capitalization: chemical symbols always start with an uppercase letter, sometimes followed by a lowercase one (for example "Na" for sodium, not "NA" or "na"). If the error message persists, the element you entered may not be in this tool's built-in table.

Formula parsing and calculation happen entirely in your browser, with no call to any external server.