How to use the grams to moles converter
- Enter the mass in grams.
- Type the chemical formula using standard element symbols, such as
H2OorCa(OH)2. - Read the calculated molar mass, moles, and total particles below.
- For moles to grams, multiply your moles by the molar mass shown in the result.
How the grams to moles calculation works
The relationship between mass and amount of substance is defined by the equation n = m / M, where n is the number of moles, m is the mass in grams, and M is the molar mass in grams per mole. The molar mass is the sum of the standard atomic weights of every atom in the chemical formula.
For example, water (H2O) contains two hydrogen atoms at 1.008 g/mol each and one oxygen atom at 15.999 g/mol. The molar mass is therefore (2 x 1.008) + 15.999 = 18.015 g/mol. If you have 36.03 grams of water, dividing by 18.015 gives exactly 2 moles.
To go from moles to grams, simply rearrange the formula: m = n x M. The calculator itself converts grams to moles; for moles to grams, multiply the moles by the molar mass shown in the result.
From grams to atoms and molecules
Once you know the number of moles, converting grams to atoms or grams to molecules uses the Avogadro constant, which is exactly 6.02214076 x 1023 particles per mole (defined by the SI system since 2019). Multiply the moles by this constant to get the total number of formula units.
If the substance is an element like iron (Fe), those units are individual atoms. If it is a compound like carbon dioxide (CO2), they are molecules. For ionic compounds like sodium chloride (NaCl), the correct term is formula units rather than molecules, but the math is identical.
To convert atoms to grams or molecules to grams, divide the particle count by the Avogadro constant to get moles, then multiply by the molar mass. This tool shows the particle count for the mass you enter.
Common molar masses reference
Below is a table of frequently used substances and their molar masses, computed from abbreviated IUPAC standard atomic weights. You can type any of these formulas into the converter above.
| Substance | Formula | Molar mass (g/mol) |
|---|---|---|
| Water | H2O | 18.015 |
| Carbon dioxide | CO2 | 44.009 |
| Sodium chloride | NaCl | 58.44 |
| Glucose | C6H12O6 | 180.156 |
| Sulfuric acid | H2SO4 | 98.072 |
| Calcium hydroxide | Ca(OH)2 | 74.092 |
| Ethanol | C2H5OH | 46.069 |
Parsing chemical formulas correctly
The formula parser reads standard element symbols: an uppercase letter optionally followed by a lowercase letter. A number immediately after an element indicates its count; if omitted, the count is 1. Parentheses group atoms, and a number after a closing parenthesis multiplies everything inside.
For instance, Ca(OH)2 means one calcium, two oxygens, and two hydrogens. Parenthesised groups like Mg3(PO4)2 (and nested groups) are also handled correctly: three magnesium, two phosphorus, and eight oxygen atoms.
A common mistake is writing element symbols in all lowercase or all uppercase; the tool is case sensitive and rejects a lowercase first letter. Co is cobalt, while CO is carbon plus oxygen (carbon monoxide); a lowercase co is rejected with an error. Always use the proper capitalization: CO for carbon monoxide. Another error is forgetting that the molar mass of a diatomic element like O2 or N2 must include the subscript 2.
Practical applications
Converting grams to moles is a foundational step in stoichiometry. When balancing a chemical reaction, coefficients represent mole ratios, not mass ratios. You must convert measured masses into moles before applying those ratios to predict product yields or limiting reagents.
In laboratory work, preparing a solution of known concentration requires dissolving a specific number of moles in a solvent. You weigh out the corresponding mass using the molar mass. For related volume-based tasks, tools like the molarity calculator extend this process to solutions. If you need to switch between mass units before calculating moles, converters such as grams to kg or ml to grams handle those steps.
Worked examples
| Example | Input | Result |
|---|---|---|
| Water | Mass (grams): 18.015; Chemical formula: H2O | Molar mass: 18.015 g/mol; Moles: 1; Particles: 6.02214 x 10^23; Mass for 1 mole: 18.015 g; Composition: H: 2, O: 1 |
| Table salt | Mass (grams): 58.44; Chemical formula: NaCl | Molar mass: 58.44 g/mol; Moles: 1; Particles: 6.02214 x 10^23; Mass for 1 mole: 58.44 g; Composition: Na: 1, Cl: 1 |
| Glucose | Mass (grams): 180.16; Chemical formula: C6H12O6 | Molar mass: 180.156 g/mol; Moles: 1.00002; Particles: 6.02227 x 10^23; Mass for 1 mole: 180.156 g; Composition: C: 6, H: 12, O: 6 |
| Carbon dioxide | Mass (grams): 44.01; Chemical formula: CO2 | Molar mass: 44.009 g/mol; Moles: 1.00002; Particles: 6.02228 x 10^23; Mass for 1 mole: 44.009 g; Composition: C: 1, O: 2 |
FAQ
How do I convert grams to moles?
Divide the mass in grams by the molar mass of the substance. The molar mass is found by adding up the atomic weights of all atoms in the chemical formula.
How do I convert moles to grams?
Multiply the number of moles by the molar mass. For example, 2 moles of water (18.015 g/mol) equals 36.03 grams.
How many atoms are in a gram of an element?
Divide 1 gram by the element's molar mass to get moles, then multiply by 6.02214076 x 10^23. For carbon-12, one gram contains about 5.018 x 10^22 atoms.
What is the difference between atoms to grams and molecules to grams?
The math is the same: divide the particle count by the Avogadro constant to get moles, then multiply by molar mass. The only difference is whether the formula represents a single element or a compound.
Does this tool use exact atomic weights?
No, not exact. It uses abbreviated IUPAC standard atomic weights (typically 4 to 5 significant figures, for example C 12.011, Cl 35.45) for elements 1 to 118, and the exact SI Avogadro constant of 6.02214076 x 10^23. Radioactive elements with no stable isotope use the mass number of a representative isotope. Results are therefore close to, but not identical to, values computed with full-precision weights.
Can I use parentheses in the formula?
Yes. Formulas like Ca(OH)2 and Mg3(PO4)2 are parsed correctly, including nested groups.
Is my data sent to a server?
No. All calculations run locally in your browser. Nothing is uploaded anywhere.