| Element | Count | Atomic wt | g/mol | Mass % |
|---|---|---|---|---|
| Na Sodium | 1 | 22.98977 | 22.98977 | 39.34 |
| Cl Chlorine | 1 | 35.45 | 35.45 | 60.66 |
| Total | 2 | 58.43977 | 100 |
Show the math
M = 1 × 22.989769 (Na) + 1 × 35.45 (Cl) = 58.43977 g/moln = m / M = 25 g / 58.43977 g/mol = 0.428 molg / (g/mol) = molN = n × NA = 0.4277909 mol × 6.02214076×1023 /mol = 2.58 × 1023Short answer: Divide the mass in grams by the molar mass in g/mol: n = m / M. 25 g of NaCl is 0.428 mol (molar mass 58.44 g/mol). To go the other way, multiply moles by the molar mass: m = n × M.
A mole is 6.022 × 10²³ particles of a substance, and the molar mass is the mass of one mole. Most wrong answers come from a wrong molar mass: a hydrate with its water left out, a bracket that was not multiplied through, or a lowercase letter that turned one element into another. This page covers both directions, with worked examples and a table of common compounds.
This article contains Amazon affiliate links. 33science earns a commission on qualifying purchases. See our affiliate disclosure.
How to use the grams to moles converter
Grams to moles formula
The formula is n = m / M. Here n is the amount in moles, m is the mass in grams and M is the molar mass in g/mol. The molar mass is the sum of the atomic weights of every atom in the formula, and its number in g/mol equals the relative molar mass (IUPAC). Atomic weights come from the CIAAW table.
Rearranged, m = n × M gives the mass. To count particles, multiply moles by the Avogadro constant, N = n × NA, where NA = 6.02214076 × 10²³ per mole, an exact value since the 2019 SI redefinition (BIPM). Large counts like these are easier to read with the scientific notation calculator.

How to convert grams to moles, step by step
Example: how many moles are in 25 g of NaCl?

Any scientific calculator handles this, and you can check the working against the converter.
Moles to grams
Multiply the amount by the molar mass: m = n × M. For 0.5 mol of NaCl, m = 0.5 mol × 58.44 g/mol = 29.22 g, or 29.2 g (29,220 mg). That sample holds 3.01 × 10²³ formula units. The same rule gives 29.1 g for 0.56 mol of chromium, a standard textbook case (LibreTexts).
Worked examples: water, a hydrate and brackets
How many moles are in 100 g of water?
The molar mass of H2O is 2 × 1.008 + 15.999 = 18.015 g/mol. Then n = 100 g / 18.015 g/mol = 5.55 mol. For the molecule count, 5.551 mol × 6.022 × 10²³ per mole = 3.343 × 10²⁴ molecules. The page for the molar mass of water lists the element breakdown.
A hydrate: CuSO4·5H2O
A hydrate carries water in its crystal, and that water counts toward the mass. CuSO4·5H2O is 159.602 g/mol for CuSO4 plus 90.075 g/mol for five H2O, a total of 249.677 g/mol. For 10 g: n = 10 g / 249.68 g/mol = 0.0401 mol of the hydrate, which contains 0.2 mol of water. Water makes up 36.1% of the mass.

Using the anhydrous mass (159.6 g/mol) on a weighed hydrate gives 0.0627 mol, which is too high. Match the formula to what was on the balance. Page for the molar mass of copper(II) sulfate pentahydrate.
Brackets: Ca(OH)2
The subscript after a bracket multiplies every atom inside it, so Ca(OH)2 holds 1 Ca, 2 O and 2 H. Its molar mass is 74.092 g/mol. For 7.4 g, n = 7.4 g / 74.092 g/mol = 0.0999 mol. Nested brackets work the same way, from the inside out.
Molar mass and moles of common compounds
Moles in 1 g is 1 / M, so the moles in any other mass scale from these columns. Each name links to its molar mass page.
| Compound | Formula | Molar mass (g/mol) | Moles in 1 g | Moles in 100 g |
|---|---|---|---|---|
| Water | H2O | 18.015 | 0.05551 | 5.551 |
| Sodium chloride | NaCl | 58.44 | 0.01711 | 1.711 |
| Glucose | C6H12O6 | 180.16 | 0.005551 | 0.5551 |
| Sucrose | C12H22O11 | 342.3 | 0.002921 | 0.2921 |
| Carbon dioxide | CO2 | 44.009 | 0.02272 | 2.272 |
| Sodium hydroxide | NaOH | 39.997 | 0.025 | 2.5 |
| Sodium bicarbonate | NaHCO3 | 84.006 | 0.0119 | 1.19 |
| Calcium carbonate | CaCO3 | 100.09 | 0.009991 | 0.9991 |
| Sulfuric acid | H2SO4 | 98.072 | 0.0102 | 1.02 |
| Hydrogen chloride | HCl | 36.458 | 0.02743 | 2.743 |
| Ammonia | NH3 | 17.031 | 0.05872 | 5.872 |
| Ethanol | C2H5OH | 46.069 | 0.02171 | 2.171 |
| Potassium permanganate | KMnO4 | 158.03 | 0.006328 | 0.6328 |
| Copper(II) sulfate pentahydrate | CuSO4·5H2O | 249.68 | 0.004005 | 0.4005 |
Other compounds with their own pages: hydrogen peroxide, acetic acid, nitric acid, aspirin, caffeine. For any formula not listed, use the molar mass calculator.
Why your answer differs from the textbook in the last digit
Textbooks round atomic weights to two decimals, such as Na 22.99, Cl 35.45 and Cu 63.55. The converter uses the full CIAAW conventional values. The molar mass changes by less than 0.1% for the compounds in the table above, and it does not change for NaCl to four digits. A difference in the third or fourth significant figure comes from this rounding, not from a wrong method. Another source is rounding the molar mass before dividing: keep extra digits until the last step.
Report the result to the precision of your least precise input. A mass given as 25 g has two significant figures, and the significant figures calculator shows how to round it. Some elements, such as carbon, hydrogen and oxygen, have atomic weights that vary slightly with the sample source, which is one more reason not to read past the fourth digit.
Common mistakes
The mg versus g slip is the most expensive: 1.39 mmol of glucose is 250 mg, but entering 250 as grams gives a thousand times too much. In mol that sample is 0.00139 mol. Small samples are easier to get right on a digital scale that reads to 0.01 g, and the converter shows the moles and millimoles side by side.
For ions, use the formula of the ion or its salt. The electron mass is too small to change the result, so Na+ and Na have the same molar mass at this precision. For the full method behind concentration problems, see the guide to calculating molarity, and to prepare a weaker solution, use the dilution calculator.
Sources
- BIPM. SI base unit: mole
- NIST. CODATA value: Avogadro constant
- IUPAC. Gold Book: molar mass
- CIAAW. Standard atomic weights
- CIAAW. Abridged atomic weights
- LibreTexts (OpenStax). Formula mass and the mole concept
- LibreTexts (Madera Community College). Conversions between moles and mass
Frequently asked questions
Add the atomic weight of every atom in the formula, counting each atom as many times as its subscript says. For NaCl, 22.989769 + 35.45 gives 58.44 g/mol.
They have the same number but different units. Molar mass is in g/mol, while molecular weight, or relative molecular mass, has no unit. Ionic compounds such as NaCl use the term formula mass.
Yes. Write the formula with plain digits for subscripts, such as Ca(OH)2 or CuSO4·5H2O. A dot or an asterisk also separates the water of hydration, and nested brackets are read from the inside out.
Capitals mark where each element symbol starts, so Co is cobalt and CO is carbon monoxide. An element written in the wrong case is read as a different element or rejected as unknown.
Multiply the sample mass by the purity as a fraction first, then convert the pure mass to moles. A 98 percent pure sample of 10 g holds 9.8 g of the compound.
A mole is a count of 6.022 x 10^23 of any particle. Molecules are the particles of covalent compounds, formula units are the smallest repeating ratio in ionic compounds, and atoms are the particles of elements.
Yes, one mole of hydrate holds one mole of the anhydrous salt plus the water. The mass is different, so use the hydrate molar mass when you weigh the hydrate.
No. If you know the molar mass in g/mol, enter it as an override and the formula is not needed. The formula is only used to calculate the molar mass.