Molar Mass Calculator

Type a chemical formula and get its molar mass, the mass each element contributes, the percent composition, and the conversion between grams, moles and molecules. Brackets, hydrates and ionic charges are all handled. Atomic weights are the IUPAC standard values, and the result tells you how many of its digits the published uncertainties actually support.

Try one:
Put this calculator on your website for free

Copy one snippet and give your visitors a working Molar Mass Calculator.

How this molar mass calculator works

Type a formula and you get its molar mass, the mass each element contributes, the percent composition, and, if you enter an amount, the conversion between grams, moles and individual molecules. The parser handles what real formulas actually look like: nested brackets in Al2(SO4)3 and K4[Fe(CN)6], the dot in a hydrate like CuSO4·5H2O, a trailing charge on an ion, and subscripts whether you type them as plain numbers or paste them from a document.

Two things here that most molar mass calculators leave out, and they are the reason this page exists. First, it tells you how many of the digits are real: IUPAC publishes an uncertainty alongside every atomic weight, and adding those up tells you where to stop writing decimals. Second, it tells you when your compound contains one of the fourteen elements whose atomic weight is no longer a single number at all. Both are things a chemistry professor will care about and a homework helper will not mention.

The formula

M = Σ (ni × Ai)
percent of element i = niAi ÷ M × 100
moles = grams ÷ M
molecules = moles × NA

M is the molar mass in grams per mole, ni is how many atoms of element i the formula contains, and Ai is that element's standard atomic weight. NA is Avogadro's constant, which since the 2019 redefinition of the SI is exactly 6.02214076 × 1023 per mole. The mole stopped being defined by a lump of carbon that year and became a defined count, so grams to molecules is now a conversion by definition rather than by measurement.

Worked example

Glucose, C6H12O6. Six carbons at 12.011, twelve hydrogens at 1.008, six oxygens at 15.999: 72.066 + 12.096 + 95.994 = 180.16 g/mol.

The composition falls out of the same three numbers: carbon is 72.066 ÷ 180.156 = 40.00% of the mass, hydrogen 6.71%, oxygen 53.28%. That 40.00% is not a coincidence worth ignoring. Glucose reduces to the empirical formula CH2O, which is one carbon and one water, which is where the word carbohydrate comes from. Notice also that the three rounded percentages add to 99.99 rather than 100.00, which is what rounding does and not an error.

And the uncertainty: 6 × 0.002 for carbon, 12 × 0.0002 for hydrogen, 6 × 0.001 for oxygen gives ±0.02 g/mol. So 180.16 is honest and 180.1559 is not. If you have 5.00 g of glucose, that is 5.00 ÷ 180.156 = 0.027754 mol, or about 1.67 × 1022 molecules.

Capital letters are part of the chemistry

Type CO and you have written carbon monoxide, 28.01 g/mol. Type Co and you have written cobalt, 58.93 g/mol. Type co and you have written nothing at all. That is not a quirk of this page, it is the notation working as designed: a capital letter starts an element symbol and a lowercase letter continues it, which is exactly how a two-letter symbol can sit next to a one-letter one with no separator and still be unambiguous.

This calculator will not silently repair your capitals, and that is deliberate. A tool that uppercases everything before parsing turns Co into CO and hands back a confident wrong answer, which is worse than an error message. When something does not parse, you get told which characters stopped it and what element you may have meant. The same rule explains why Cs is cesium rather than carbon-plus-sulfur, and why NaCl cannot be misread even though N, Na, C and Cl are all real symbols.

Ionic charges get the same treatment, for the same reason. A bare sign is never ambiguous, so Na+ and OH- work exactly as typed and the charge is simply set aside, which is right to about one part in a hundred thousand: an electron does have mass, just not enough to reach the digits anyone prints. But SO42- is genuinely ambiguous. It could be sulfate carrying a 2- charge, or it could be forty-two of something carrying 1-, and those weigh 96.06 and 48.06 g/mol respectively. Rather than pick one and sound certain, this page hands it back and asks you to write SO4^2- or SO4 2-, either of which says exactly what you mean. That is the same position our order of operations calculator takes on 8/2(2+2): when notation is genuinely ambiguous, the useful answer is to name the ambiguity rather than to guess confidently.

The atomic weights are not single numbers any more

Here is the part that surprises people who learned chemistry before about 2010. For fourteen elements, IUPAC no longer publishes a standard atomic weight as one number. It publishes an interval, because the isotopic composition of normal terrestrial material genuinely varies from sample to sample by more than anyone can measure. Carbon is [12.0096, 12.0116]. Sulfur is [32.059, 32.076]. The full list is hydrogen, lithium, boron, carbon, nitrogen, oxygen, magnesium, silicon, sulfur, chlorine, argon, bromine, thallium and lead, and the last two of those joined only in the 2021 report.

Lead is the spectacular one: [206.14, 207.94]. That is a spread of nearly a whole mass unit, 0.87%, and the reason is a genuinely lovely piece of geology. Lead sits at the end of three separate radioactive decay chains, so the mix of lead isotopes in an ore depends on how much uranium and thorium were sitting next to it and for how long. A lead sample carries the history of the rock it came from, and that history shows up in its molar mass. So when this page computes a lead compound and warns you about the digits, it is not being fussy; the number really does depend on which mine the lead came out of.

What this calculator uses, like every periodic table on every classroom wall, is the conventional atomic weight: a single agreed value chosen to represent the interval when a single value is what you need. That is the right choice for teaching, homework and commerce. It is the wrong choice for isotope geochemistry, and the page tells you when your compound is one where the distinction bites.

Molar mass, molecular weight, formula weight: which word is right

These get used interchangeably and they are not the same thing, which matters more in an exam than in a lab. Molar mass is the mass of one mole, and it has units of g/mol. Relative molecular mass (Mr, the thing most people mean when they say molecular weight) is a ratio of the molecule's mass to one twelfth of a carbon-12 atom, so it is dimensionless. The two are numerically identical, which is exactly why nobody notices they are different quantities, and why a marked answer that says "180.16" without units can go either way.

The sharper distinction is formula weight. Sodium chloride has no molecules. Solid NaCl is a lattice in which every sodium ion is surrounded by six chlorides, and there is no group of two atoms you could point at and call a molecule. So "the molecular weight of NaCl" is describing something that does not exist; the correct term is formula weight, the mass of one formula unit. The number is still 58.44, and every result on this page is honest for both cases, but if your professor is the sort to circle it, they are right to.

Sources

Where the numbers on this page come from. We go to the body that publishes the figure, not to another calculator. See how we verify.

Frequently asked questions

How do you calculate molar mass from a chemical formula?

Multiply each element's standard atomic weight by the number of its atoms in the formula, then add the products. Glucose, C6H12O6, is 6 times 12.011 plus 12 times 1.008 plus 6 times 15.999, which is 180.16 g/mol. Brackets multiply everything inside them, so Al2(SO4)3 contains 2 aluminums, 3 sulfurs and 12 oxygens, and the dot in a hydrate such as CuSO4.5H2O just means the water is counted too.

Is molar mass the same as molecular weight?

Numerically yes, conceptually no. Molar mass is the mass of one mole and carries units of g/mol. Relative molecular mass, which is what molecular weight usually means, is a ratio against one twelfth of a carbon-12 atom and is dimensionless. For an ionic compound like NaCl neither term is quite right, because there is no molecule to weigh: the correct term is formula weight, the mass of one formula unit. The number is 58.44 either way.

Why does capitalization matter in a chemical formula?

Because it is what separates one element from another with no punctuation in between. CO is carbon monoxide at 28.01 g/mol and Co is cobalt at 58.93 g/mol. A capital letter starts a symbol and a lowercase letter continues it, which is how NaCl can be read unambiguously even though N, Na, C and Cl are all real symbols. This calculator will not quietly fix your capitals, because doing so would turn a typo into a confident wrong answer.

How many decimal places should I give a molar mass?

As many as the atomic weights support, and usually fewer than a calculator offers. IUPAC publishes an uncertainty with every atomic weight, so a molar mass has one too: glucose is 180.16 plus or minus 0.02 g/mol, which makes two decimal places honest and four decorative. This page adds those uncertainties up and tells you where to stop. In practice most classroom work wants two decimal places, and matching the precision of your least precise measurement matters more than either.

Why do some elements have a range instead of an atomic weight?

Because their isotopic composition varies from sample to sample by more than anyone can measure. IUPAC publishes an interval for fourteen elements: hydrogen, lithium, boron, carbon, nitrogen, oxygen, magnesium, silicon, sulfur, chlorine, argon, bromine, thallium and lead. Carbon is [12.0096, 12.0116]. Lead is [206.14, 207.94], a spread of nearly a full mass unit, because lead is the end product of three radioactive decay chains and its isotope mix depends on the uranium and thorium history of the ore. For a single number, everyone uses the conventional atomic weight, which is what this page does.

What do the square brackets around some atomic weights mean?

That the element has no stable isotope, so it has no standard atomic weight at all. The bracketed figure is the mass number of its longest-lived isotope, which is a label rather than a measurement: technetium is shown as [98] and plutonium as [244]. Any molar mass containing one of these elements depends on which isotope you actually have, so treat it as a nominal value and not a weighing.

How do I convert grams to moles?

Divide the mass by the molar mass. Five grams of glucose is 5 divided by 180.156, which is 0.027754 mol. Going the other way, multiply moles by molar mass. To reach individual molecules, multiply moles by Avogadro's constant, which has been exactly 6.02214076 times 10 to the 23rd per mole since the SI was redefined in 2019, so that step is now a definition rather than a measurement. Enter an amount above and all three appear together.

Can this calculator handle hydrates and polyatomic ions?

Yes. Write a hydrate with a dot, as CuSO4.5H2O, and the number in front of the water multiplies it; that compound comes to 249.68 g/mol, of which 36.08% is the water that a drying oven would remove. Brackets nest, so K4[Fe(CN)6] parses correctly, and square brackets and braces are treated the same as parentheses. A trailing charge such as SO4 2- is accepted and ignored for the mass, which is right to about one part in a hundred thousand: an electron does weigh something, just not enough to show.

Related calculators