Molar mass is the sum of atomic weights in a formula: H2O = 2(1.008) + 15.999 = 18.015 g/mol, and glucose C6H12O6 = 180.156 g/mol. Type any formula below, including parentheses and hydrates like CuSO4·5H2O (249.677 g/mol), for the total plus a per-element breakdown.

Chemical Formula

Ad
H2O CO2 NaCl Ca(OH)2 H2SO4 Al2(SO4)3 CuSO4·5H2O C9H8O4
Molar Mass
—
ElementAtomic Mass (g/mol)CountSubtotal (g/mol)

Grams ⇄ Moles

Moles in your sample
—
Molecules / formula units
—
Ad

Molar Mass of Common Compounds

CompoundFormulaMolar Mass (g/mol)
WaterH2O18.015
MethaneCH416.043
AmmoniaNH317.031
Nitrogen gasN228.014
Oxygen gasO231.998
Hydrochloric acidHCl36.458
Sodium hydroxideNaOH39.997
EthanolC2H5OH46.069
Carbon dioxideCO244.009
Table saltNaCl58.440
Baking sodaNaHCO384.006
Sulfuric acidH2SO498.072
LimestoneCaCO3100.086
Slaked limeCa(OH)274.092
RustFe2O3159.687
Aluminum sulfateAl2(SO4)3342.132
Magnesium nitrateMg(NO3)2148.313
Potassium permanganateKMnO4158.032
Copper(II) sulfate, anhydrousCuSO4159.602
Copper(II) sulfate pentahydrateCuSO4·5H2O249.677
AspirinC9H8O4180.159
GlucoseC6H12O6180.156

Values use IUPAC 2021 conventional atomic weights (C 12.011, H 1.008, O 15.999, S 32.06, Cu 63.546). Your textbook's table may differ in the third decimal if it rounds differently.

How the Molar Mass Calculator Works

Type a formula, get grams per mole. The calculator parses the formula the way your chemistry teacher does: each element symbol carries a count (no subscript means one), parentheses distribute their multiplier across everything inside them, a leading coefficient multiplies the whole group, and a hydrate dot adds waters of hydration. It then sums count × atomic weight for every element and shows the work.

The formula

M = Σ (atomic weight × atom count). For C6H12O6 that's 6 × 12.011 + 12 × 1.008 + 6 × 15.999 = 72.066 + 12.096 + 95.994 = 180.156 g/mol. For a hydrate, CuSO4·5H2O = 159.602 + 5 × 18.015 = 159.602 + 90.075 = 249.677 g/mol. The grams-to-moles card divides mass by the result: n = m ÷ M, and moles × 6.022 × 10²³ gives particle count.

How to use it

Enter the formula with proper capitalization (Co is cobalt, CO is carbon monoxide, and the calculator will not guess for you). Parentheses and multipliers work to any depth, so K4Fe(CN)6 and CH3(CH2)3CH3 both parse. Click any example chip to load it. Edit the mass field and the mole card converts instantly; type into the mole field instead and it works in reverse.

A worked example

How many moles are in 25.0 g of glucose? Molar mass first: 180.156 g/mol from the table above. Then n = 25.0 ÷ 180.156 = 0.1388 mol, which holds 0.1388 × 6.022 × 10²³ ≈ 8.36 × 10²² molecules. Now run it backward for a lab prep: to measure out 0.75 mol of NaCl you'd weigh 0.75 × 58.440 = 43.83 g.

One thing that trips up first-year students: molar mass (in g/mol) and molecular weight (a relative mass with no units, or the same number in daltons per molecule) are numerically identical. Only the label changes. For ionic salts like NaCl there aren't discrete molecules, so chemists call it formula weight instead, but it's the same number and it works the same way in stoichiometry.

What does the breakdown table actually show?

Every row under the result is one element: its atomic weight, how many atoms of it the formula contains, and the product of the two. The subtotals add up to the molar mass. Here's the table the calculator builds for potassium ferrocyanide, K4Fe(CN)6, a formula that tests both a plain subscript and a parenthesized group.

ElementCountAtomic weight (g/mol)Subtotal (g/mol)
K (potassium)439.0984 × 39.098 = 156.392
Fe (iron)155.8451 × 55.845 = 55.845
C (carbon)612.0116 × 12.011 = 72.066
N (nitrogen)614.0076 × 14.007 = 84.042
Total368.345

Notice how the (CN)6 group became six carbons and six nitrogens. That's the distribution step people skip when they do it by hand. If you forget it, you'll get 4 × 39.098 + 55.845 + 12.011 + 14.007 = 238.255, which is way off.

Percent composition from the same table

Divide any subtotal by the total and multiply by 100 to get that element's mass percent. Water is 2.016 ÷ 18.015 = 11.19% hydrogen and 88.81% oxygen. Glucose works out to 40.00% carbon, 6.71% hydrogen and 53.28% oxygen. For a hydrate you can do the same with the water as a block: in CuSO4·5H2O, 90.075 ÷ 249.677 means 36.08% of the crystal's mass is water, which is why it loses over a third of its weight when you heat it.

More molar masses: hydrates, acids and everyday chemicals

These extend the table above. Every value comes from the same atomic weights the calculator uses, so you'll get these exact numbers if you type the formula in.

CompoundFormula to typeMolar Mass (g/mol)
Acetic acid (vinegar)CH3COOH60.052
Nitric acidHNO363.012
Potassium chlorideKCl74.548
Ammonium nitrateNH4NO380.043
Phosphoric acidH3PO497.994
Potassium nitrateKNO3101.102
Calcium chlorideCaCl2110.978
OctaneC8H18114.232
Ammonium sulfate(NH4)2SO4132.134
Calcium chloride dihydrateCaCl2·2H2O147.008
Silver nitrateAgNO3169.874
GypsumCaSO4·2H2O172.164
Citric acidC6H8O7192.123
CaffeineC8H10N4O2194.194
Epsom saltMgSO4·7H2O246.466
Washing sodaNa2CO3·10H2O286.138
Calcium phosphateCa3(PO4)2310.174
Sucrose (table sugar)C12H22O11342.297
BoraxNa2B4O7·10H2O381.363
Potassium alumKAl(SO4)2·12H2O474.372

What can you type, and what will the calculator reject?

The parser is strict on purpose. It would rather show an error than hand you a plausible-looking wrong answer. Here's what it handles:

Element symbols from H to U. All 92 naturally occurring elements are in its table, hydrogen through uranium. Symbols must start with a capital letter, with an optional lowercase second letter. Synthetic elements past uranium (Np, Pu and so on) and isotope labels like D for deuterium aren't included, so they return "Unknown element".

Subscripts, parentheses and leading coefficients. Write subscripts as plain digits after the symbol. Parentheses can nest, and the number after a closing parenthesis multiplies everything inside. A number at the very start multiplies the whole formula, so 2H2O gives 36.030. Spaces are ignored.

One hydrate dot. Use ·, a period, * or ~ between the salt and the water, as in MgSO4·7H2O. The number right after the dot applies to the water.

And here's what doesn't work:

Lowercase formulas. h2o returns "Unexpected character". Capitals matter because CO (carbon monoxide, 28.010) and Co (cobalt, 58.933) are different things.

Square brackets and charges. Rewrite [Cu(NH3)4]SO4 as Cu(NH3)4SO4 (227.726 g/mol). Ion charges like SO4^2- aren't accepted. Drop the charge, since electrons don't change the mass at three decimals anyway.

Fractions and decimal subscripts. The ½ symbol is rejected. Because a period counts as a hydrate dot, decimal subscripts such as Fe0.95O won't be read as decimals at all, and the result won't mean anything. For plaster of Paris (CaSO4·½H2O), type (CaSO4)2·H2O to get 290.283 and halve it: 145.14 g/mol.

A coefficient in front of a hydrate. The leading number multiplies the water too, so 2CaSO4·H2O comes out as 308.298, not 290.283. Use parentheses instead, as shown above.

A number inside an opening parenthesis. (2H2O) is an error. Put the multiplier after the group: (H2O)2.

Why doesn't my answer match the textbook exactly?

Usually it's rounding in the atomic weight table, not a mistake. This calculator uses IUPAC's abridged values: chlorine is 35.45, sulfur 32.06, lithium 6.94. Older books often print 35.453 for chlorine or 32.065 for sulfur, and some round everything to two decimals (H 1.01, O 16.00). That's why NaCl shows up as 58.44 in one source and 58.443 in another. For lab work, the third decimal almost never matters, because your balance probably isn't that precise. If your teacher wants a specific table, match their values and you'll match their key.

Frequently Asked Questions

What is molar mass?

Molar mass is the mass of one mole of a substance, in grams per mole (g/mol). Numerically it equals the sum of the atomic weights of every atom in the chemical formula: water (H2O) is 2 × 1.008 + 15.999 = 18.015 g/mol, and glucose (C6H12O6) is 6 × 12.011 + 12 × 1.008 + 6 × 15.999 = 180.156 g/mol. One mole always contains 6.022 × 10²³ particles, so molar mass is the bridge between grams on a scale and molecules in a flask.

How do you calculate molar mass from a formula?

Write out the formula, list each element with its count (multiplying through any parentheses), look up each element's atomic weight, multiply by the count, and add the subtotals. For Ca(OH)2: calcium 40.078, plus 2 × oxygen (15.999), plus 2 × hydrogen (1.008), which totals 74.092 g/mol. The calculator automates exactly this, including nested groups like Al2(SO4)3 (342.132 g/mol).

What is the molar mass of water?

18.015 g/mol. Two hydrogens at 1.008 each plus one oxygen at 15.999 sum to 18.015 grams per mole, so one mole of water weighs 18.015 grams, about 18 milliliters.

How do you handle hydrates like CuSO4·5H2O?

Multiply the water count through the whole H2O unit and add it to the anhydrous salt. Copper(II) sulfate pentahydrate is CuSO4 (159.602 g/mol) plus 5 × H2O (5 × 18.015 = 90.075), totaling 249.677 g/mol. The calculator accepts the dot written as ·, ., *, or ~.

How do you convert grams to moles?

Divide mass by molar mass: moles = grams ÷ g/mol. For 25.0 g of glucose, 25.0 ÷ 180.156 = 0.1388 mol. Going the other way, grams = moles × molar mass, so 0.75 mol of NaCl weighs 0.75 × 58.440 = 43.83 g. Multiply moles by 6.022 × 10²³ if you need particle counts.

How do I find percent composition from molar mass?

Divide each element's subtotal by the total molar mass and multiply by 100. Water's two hydrogens weigh 2.016 g/mol out of 18.015, so it's 11.19% hydrogen and 88.81% oxygen. Glucose is 40.00% carbon, 6.71% hydrogen and 53.28% oxygen. The breakdown table gives you every subtotal you need.

Why does the calculator say "Unexpected character" or "Unknown element"?

"Unexpected character" means the formula has something the parser can't read: a lowercase first letter (h2o), square brackets, a charge like ^2-, a fraction symbol, or a number right after an opening parenthesis. "Unknown element" means the symbol isn't in its table of elements H through U, which often happens with a capitalization slip like No or Cn. Fix the symbol and the result appears straight away.

Can I enter square brackets, charges or decimal subscripts?

No. Swap square brackets for parentheses, so [Cu(NH3)4]SO4 becomes Cu(NH3)4SO4 (227.726 g/mol), and leave charges off. Decimal subscripts don't work because a period is read as a hydrate dot. For a half-hydrate like CaSO4·½H2O, enter (CaSO4)2·H2O (290.283 g/mol) and divide by 2 to get 145.14 g/mol.

Why is my answer slightly different from my textbook?

Different atomic weight tables round differently. This calculator uses IUPAC abridged values such as Cl 35.45 and S 32.06, while some books use 35.453 and 32.065, or round to H 1.01 and O 16.00. The gap is usually in the second or third decimal place, which is smaller than most lab balances can measure.