This calculator turns a mass in grams into an amount of substance in moles. Enter the mass you weighed and the molar mass of the compound; you get the moles, the same amount in millimoles and the number of formula units (molecules, or ion pairs for a salt).
Formula
n = m ÷ M, and N = n × NA.
- n: amount of substance in moles (mol)
- m: mass in grams (g)
- M: molar mass in grams per mole (g/mol), the sum of the atomic weights in the formula
- N: number of formula units; NA = 6.02214076 × 1023 mol−1 (the Avogadro constant, exact)
- 1 mol = 1000 mmol
Worked Example
25 g of sodium chloride, NaCl, with a molar mass of 58.44 g/mol (22.990 for Na + 35.45 for Cl).
- n = 25 ÷ 58.44 = 0.4278 mol
- In millimoles: 0.42779 × 1000 = 427.79 mmol
- Formula units: 0.42779 × 6.02214076 × 1023 = 2.576 × 1023
Assumptions
- The molar mass is that of the exact substance you weighed, including any water of crystallisation (CuSO4·5H2O, not CuSO4).
- The sample is pure; for a reagent of known purity, multiply the mass by the purity fraction first.
- Masses are in grams; convert milligrams (÷ 1000) or kilograms (× 1000) before you enter them.
How to read the result
The amount in moles is what reaction equations and concentrations are written in, so it is the number to carry into a stoichiometry or molarity calculation. The number of formula units is mainly a check of scale: even a few milligrams hold around 1019 to 1020 of them. Use the molar mass calculator if you do not have M yet.
Limits and common mistakes
- Using the anhydrous molar mass for a hydrate (or the reverse) is the most common error and can be off by 30% or more.
- Entering milligrams as grams gives an answer 1000 times too large.
- For a solution, the mass of solute is not the mass of the solution; use a molarity calculator instead.
Frequently Asked Questions
How many moles are in 25 g of NaCl?
About 0.4278 mol, using M = 58.44 g/mol.
What is the formula for grams to moles?
Moles = grams ÷ molar mass (g/mol).
Where do I find the molar mass?
Add the atomic weights of every atom in the formula, or type the formula into the molar mass calculator on the home page.
Does the result count molecules or atoms?
Formula units: molecules for a molecular compound, one cation-anion set for a salt such as NaCl. For atoms, multiply by the number of atoms in the formula.
Formula used
in m | Mass of the sample | g | 25 | 0 in mm | Molar mass | g/mol | 58.44 | 0.001 out n | Amount of substance | mol | m / mm | 4 out mmol | Amount in millimoles | mmol | n * 1000 | 2 out nn | Number of formula units | - | n * 6.02214076e23 | 3
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation with the constants and conversion factors written on the page, rounded as each result states. See method and constants, the disclaimer or report an error.
More in this section
- Molecules to Grams Calculator: Convert with Molar Mass18.0150 g
- How Many Protons Are in Potassium (K)?19 protons
- Moles of Electrons: Formula and Calculator
- Molecules to Liters Calculator: Convert Using Molarity0.1000 L
- How to Calculate mL to Moles: Formula and Calculator0.1250 mol
- Free Energy Change Calculation: ΔG Formula and Example-24.907 kJ/mol