Molecular weight calculator
Parse a chemical formula and sum the element masses into a molar mass.
What this calculator covers
Use this calculator when you have a chemical formula string and want its molar mass without building the element subtotal table manually.
The parser supports standard element symbols, positive integer subscripts, and parenthesized groups. It intentionally rejects shorthand such as hydrate dots, charge notation, and isotope labels.
Frequently asked questions
- What input format does this calculator accept?
- Enter a standard chemical formula using capitalized element symbols followed by integer subscripts — for example H2O, NaCl, or Ca(OH)2. Spaces are ignored. Hydrate dots, ionic charges, isotope prefixes, and subscript Unicode characters are not supported and will produce an error.
- What are the atomic masses based on?
- The calculator uses average atomic masses from a built-in periodic-table reference covering all elements. Average masses account for the natural isotope distribution of each element, which is why hydrogen shows 1.008 rather than exactly 1.
- Why does the result use units of g/mol?
- Molar mass expresses the mass of one mole of a substance in grams. One mole contains approximately 6.022 × 10²³ formula units, so grams per mole is the standard unit that connects the atomic scale to laboratory-scale quantities.
- Can I calculate the molar mass of an ionic compound like NaCl?
- Yes. Enter the formula exactly as written — NaCl, MgCl2, Ca3(PO4)2 — and the parser will expand the groups, count each element, and sum the atomic-mass contributions. Ionic charge notation such as Ca²⁺ is not supported, so omit it.
Tool
Run the calculation
Result
RESULT · MOLAR MASS
№199
Primary result
18.0150 g/mol
H2O has a molar mass of 18.0150 g/mol.
- H
- 2 x 1.008 = 2.016 g/mol
- O
- 1 x 15.999 = 15.999 g/mol
Step-by-step solution
- 1.Tokenize the formula string, expand any parenthesized groups, and sum the final count for each element symbol.
- 2.Multiply each element count by its built-in average atomic mass constant.
- 3.Add the element contributions together to get the total molar mass in g/mol.
Walkthrough
Visual walkthrough
Molecular weight is an accounting problem: count atoms correctly, then add their average atomic masses.
01
Parse the formula
H2O
The parser supports plain element symbols, positive integer subscripts, and parenthesized groups such as Ca(OH)2.
02
Build each element subtotal
H: 2 x 1.008; O: 1 x 15.999
Every element contributes its count multiplied by the corresponding atomic-mass constant.
03
Sum the subtotals
The final total is the molar mass in grams per mole for the parsed formula.
18.0150 g/mol