Molar Mass Calculator
Calculate the molar mass of a compound from its chemical formula.
Learn more
What it does
The Molar Mass Calculator turns a chemical formula into the mass of one mole of that substance, in grams per mole, and breaks the total down element by element. Type a formula such as H2O, Ca(OH)2 or K4[ON(SO3)2]2, and nested parentheses, square brackets and subscripts are all understood. You get the total molar mass plus each element contribution and its mass percent, ready to copy or export as CSV. It is a daily tool for chemistry students, prep labs and anyone crossing between grams and moles, and because the calculation runs entirely in your browser there is nothing to sign up for and no formula leaves your device.
How it works
Molar mass M is the mass of one mole of a substance and equals the sum of the atomic masses of every atom in the formula: M = the sum over elements of n_i times A_r,i, where n_i is how many times element i appears and A_r,i is its standard relative atomic mass. This tool uses the IUPAC 2021 standard atomic weights, for example H 1.008, C 12.011, N 14.007, O 15.999, Na 22.99, Cl 35.45, Cu 63.546. The parser is a recursive descent reader. It strips all whitespace, treats square brackets exactly like round ones, reads an element symbol as one capital letter followed by optional lower case letters, and multiplies a bracketed group by whatever subscript follows the closing bracket. Ca(OH)2 therefore expands to Ca plus two copies of (O + H), and K4[ON(SO3)2]2 expands to K4 O14 N2 S4. A hydrate dot is read as multiplication, so CuSO4·5H2O becomes (CuSO4)(5H2O) and all five waters count, and a leading number multiplies the whole formula, so 2H2O is two waters rather than one. Because those atomic weights are averages over the natural isotopic mix of each element, the sum carries decimals, which is why glucose C6H12O6 comes out as 180.156 rather than a round 180.
Worked example
Glucose C6H12O6: carbon 6 times 12.011 = 72.066, or 40.00 percent of the mass; hydrogen 12 times 1.008 = 12.096, or 6.71 percent; oxygen 6 times 15.999 = 95.994, or 53.28 percent. The total is 180.156 g/mol. A bracketed group scales the same way, so calcium hydroxide Ca(OH)2 is 40.078 + 2 times (15.999 + 1.008) = 74.092 g/mol. Nested brackets are handled by recursion rather than pattern matching, which is why the fertiliser K4[ON(SO3)2]2 returns 536.632 g/mol after expanding to K4 O14 N2 S4. Hydrates are worth working through because they are weighed as if the water were not there: copper sulfate pentahydrate CuSO4·5H2O is 63.546 + 32.06 + 4 times 15.999 = 159.602 for the sulfate part, plus 5 times 18.015 = 90.075 for the five waters, giving 249.677 g/mol. The same value comes back from the expanded form CuSO4H10O5, and CaCl2·6H2O returns 219.068 g/mol. Two more reference points worth memorising: water is 2 times 1.008 + 15.999 = 18.015 g/mol, and sodium chloride is 22.99 + 35.45 = 58.44 g/mol, the number you need before weighing out a 0.100 M solution.
When to use it
Reach for it before any calculation that crosses between grams and moles: working out the reagent mass for a target molarity, converting a recipe from percent to molar, or checking the molecular weight printed on a bottle. Hydrated salts are the case worth dwelling on, because a formula that mentions water is routinely weighed as if the water were not there. Copper sulfate pentahydrate CuSO4·5H2O is 249.677 g/mol, not the 159.602 g/mol of the anhydrous salt; weighing out 159.6 g of the blue crystals instead of 249.7 g leaves the solution about 36 percent low in copper, and nothing in the procedure would look wrong. The hydrate dot, the asterisk and the middle dot all work, as do the expanded form CuSO4H10O5 and Unicode subscripts such as H₂O. Capitalisation is still exact: element symbols must match the periodic table, so na is not sodium and is listed as unrecognised along with anything else the parser cannot place. When something is reported as unrecognised the mass shown covers only the part that was understood, so the warning is worth reading rather than scrolling past.
FAQ
- How is molar mass calculated from a chemical formula?
- Multiply the standard atomic weight of each element by the number of times it appears in the formula and add the results: M = Σ (n × A_r). For glucose C6H12O6 that is 6 × 12.011 + 12 × 1.008 + 6 × 15.999 = 180.156 g/mol. A subscript after a closing bracket multiplies the whole group, so Ca(OH)2 counts O and H twice.
- Why is molar mass different from molecular weight?
- The two share the same number but not the same unit. Molar mass is expressed in g/mol and refers to one mole of the substance; molecular weight is a dimensionless ratio to one twelfth of the mass of a carbon-12 atom. Because both are built from the same averaged atomic weights, the terms are used interchangeably in practice: the 180.156 obtained for glucose is both its molar mass in g/mol and its molecular weight.
- How does the calculator handle parentheses and square brackets?
- Both are treated as grouping symbols and either can be nested. The parser reads the group, multiplies it by the subscript that follows the closing bracket, and hands the result back to its parent. Ca(OH)2 is Ca + 2 × (O + H) = 74.092 g/mol, and K4[ON(SO3)2]2 expands to K4 O14 N2 S4 = 536.632 g/mol.
- How are hydrates such as CuSO4·5H2O handled?
- The dot is read as multiplication, so CuSO4·5H2O is expanded to (CuSO4)(5H2O) and the five waters count in full: 63.546 + 32.06 + 4 times 15.999 = 159.602 for the sulfate part, plus 5 times 18.015 = 90.075 for the water, giving 249.677 g/mol. The expanded form CuSO4H10O5 returns the same number. This matters because the anhydrous salt is 159.602 g/mol, so weighing the blue crystals as if they were anhydrous understates the molar mass by 36 percent. Decimals elsewhere in the result are normal: standard atomic weights are averages over the natural isotopic composition of each element, so H is 1.008, C 12.011 and O 15.999, and sums are rarely whole numbers.