Grams to Moles Calculator
Enter a chemical formula and mass in grams to get moles instantly, with full element breakdown and molar mass.
Supports parentheses: Ca(OH)₂, Fe₂(SO₄)₃, Cu(NH₃)₄²⁺
Quick Formulas
Moles
—
mol
Molar Mass
—
g/mol
Formula
—
Element Breakdown
| Element | Count | Atomic Mass | Contribution |
|---|---|---|---|
| Molar Mass | |||
Embed This Calculator
Copy the code and paste it into any webpage to embed this calculator.
WordPress users: add a Custom HTML block (not the Embed block) and paste the code there.
Free to use. A small "Powered by Blucalculator" credit is appreciated but not required.
How to use this calculator
Two inputs. That’s the entire interface.
Chemical formula — Type it in standard notation. The calculator reads each element symbol, subscript, and parenthetical group and parses the full molecular composition. Accepted formats include simple compounds (H2O, NaCl, CO2, NH3), compounds with parentheses (Ca(OH)2, Al2(SO4)3), organic molecules (C6H12O6, C2H5OH), hydrates (CuSO4·5H2O, Na2CO3·10H2O), and complex inorganics (Fe2(SO4)3, KMnO4).
Mass in grams — Enter the mass of your sample. If you weighed it on a lab balance, enter the number directly. If your problem gives you milligrams, convert first by dividing by 1,000.
After clicking Calculate, you get the total moles (primary result), molar mass in g/mol, and an element-by-element breakdown showing how molar mass was computed.
Quick example — sodium chloride
Formula: NaCl / Mass: 117 g
Na = 22.990 g/mol × 1 = 22.990 Cl = 35.453 g/mol × 1 = 35.453 Total molar mass = 58.443 g/mol
Moles = 117 ÷ 58.443 = 2.002 mol
Approximately 2 moles of sodium chloride.
If your formula includes a hydrate (like CuSO4·5H2O), enter the dot using a period or the middle dot character. The calculator includes all bound water molecules in the molar mass — because they are part of the compound by weight, not an impurity.
Why the gram-to-mole conversion matters
Chemistry equations don’t describe mass. They describe particle ratios.
When you see 2H₂ + O₂ → 2H₂O, the equation says two molecules of hydrogen gas react with one molecule of oxygen to produce two molecules of water. Scale that up by Avogadro’s number (6.022 × 10²³) and you get the same ratio in moles: two moles of H₂ react with one mole of O₂ to produce two moles of H₂O.
The problem is that you can’t measure moles on a scale. You measure grams. To actually run this reaction in a lab, you need to convert the mole ratio into grams. That conversion step sits at the centre of nearly every stoichiometry calculation. Get it wrong once and the entire downstream result is off by the same ratio.
Grams tell you how much the sample weighs. Moles tell you how many particles it contains. Chemistry equations need the second number.
The formula
One division. That’s it.
The molar mass is the number you look up or calculate. It’s the mass of one mole of the substance in grams per mole. For any compound, it equals the sum of the atomic masses of every atom in the formula.
Hydrogen has an atomic mass of 1.008. Oxygen is 15.999. For H₂O: (2 × 1.008) + 15.999 = 18.015 g/mol.
How molar mass is calculated element by element
Take Ca(OH)₂ as a worked example, because it’s where most students make their first parentheses error.
| Element | Atom count | Atomic mass (g/mol) | Contribution |
|---|---|---|---|
| Ca | 1 | 40.078 | 40.078 |
| O | 2 (from OH × 2) | 15.999 | 31.998 |
| H | 2 (from OH × 2) | 1.008 | 2.016 |
| Total | 74.092 g/mol |
The subscript 2 after the closing parenthesis multiplies every atom inside the brackets by 2. So (OH)₂ means 2 oxygen atoms and 2 hydrogen atoms.
A common mistake is reading it as Ca + O + 2H = 40.078 + 15.999 + 2.016 = 58.093 g/mol. That’s wrong by 16 g/mol — a 27% error — because one oxygen atom was lost.
Ca(OH)₂ and CaOH₂ are not the same formula. The first has 2 oxygens. The second, if interpreted literally, has 1. Always enter the correct formula with parentheses intact. The calculator parses them correctly — but only if you type them.
Molar masses of common compounds
| Compound | Formula | Molar mass (g/mol) | Note |
|---|---|---|---|
| Water | H₂O | 18.015 | Universal reference |
| Carbon dioxide | CO₂ | 44.009 | Common in gas problems |
| Sodium chloride | NaCl | 58.443 | Table salt |
| Ammonia | NH₃ | 17.031 | Industrial base |
| Glucose | C₆H₁₂O₆ | 180.156 | Common in biology |
| Sulfuric acid | H₂SO₄ | 98.072 | Strong acid |
| Sodium hydroxide | NaOH | 39.997 | Strong base (lye) |
| Calcium carbonate | CaCO₃ | 100.086 | Limestone, chalk |
| Hydrochloric acid | HCl | 36.461 | Strong acid |
| Ethanol | C₂H₅OH | 46.068 | Alcohol |
| Copper sulfate pentahydrate | CuSO₄·5H₂O | 249.679 | Hydrate example |
| Iron oxide | Fe₂O₃ | 159.687 | Rust |
| Potassium permanganate | KMnO₄ | 158.034 | Oxidising agent |
Real worked examples
36 grams of water
Formula: H₂O / Molar mass: 18.015 g/mol / Mass: 36 g
Moles = 36 ÷ 18.015 = 1.999 mol ≈ 2 mol
36 grams of water contains almost exactly 2 moles. Since 1 mole of water contains 6.022 × 10²³ molecules, 2 moles contains 1.204 × 10²⁴ water molecules.
117 grams of sodium chloride
Formula: NaCl / Molar mass: 58.443 g/mol / Mass: 117 g
Moles = 117 ÷ 58.443 = 2.002 mol ≈ 2 mol
This is a common textbook number. 117 g of NaCl is designed to give a clean whole-number answer.
180 grams of glucose
Formula: C₆H₁₂O₆ / Molar mass: 180.156 g/mol / Mass: 180 g
Moles = 180 ÷ 180.156 = 0.999 mol ≈ 1 mol
One mole of glucose weighs about 180 grams. This is why glucose solutions in medicine are often expressed in molar terms: a 1M glucose solution contains 180 grams of glucose per litre of solution.
Copper sulfate pentahydrate
Formula: CuSO₄·5H₂O / Molar mass: 249.679 g/mol / Mass: 124.84 g
Moles = 124.84 ÷ 249.679 = 0.500 mol
The five water molecules (5 × 18.015 = 90.075 g/mol) are included in the molar mass. Using anhydrous CuSO₄ (159.60 g/mol) instead gives 0.782 mol — wrong by 56%.
Stoichiometry: why mole ratios matter
Balanced equations give you mole ratios, not gram ratios. This is the entire foundation of stoichiometry.
Consider the synthesis of water. The balanced equation is 2H₂ + O₂ → 2H₂O, which gives a mole ratio of 2 mol H₂ : 1 mol O₂ : 2 mol H₂O.
If you start with 4 grams of hydrogen:
Stoichiometry chain — hydrogen combustion
Moles of H₂ = 4 ÷ 2.016 = 1.984 mol
From the ratio: 1.984 mol H₂ requires 0.992 mol O₂ Mass of O₂ needed = 0.992 × 31.998 = 31.74 g
From the ratio: 1.984 mol H₂ produces 1.984 mol H₂O Mass of H₂O produced = 1.984 × 18.015 = 35.74 g
Every step in that chain goes through the grams-to-moles conversion. The conversion itself is simple. The complexity is in tracking which substance you’re converting and which ratio from the balanced equation applies.
The stoichiometry pattern never changes: grams of A → moles of A (÷ molar mass of A) → moles of B (× mole ratio from equation) → grams of B (× molar mass of B). Every stoichiometry calculation follows this exact sequence.
Common mistakes
Subscript errors. CO has a molar mass of 28.010 g/mol (C + O). CO₂ has a molar mass of 44.009 g/mol (C + 2O). These are different compounds. The subscript 2 isn’t a minor detail — calculating with CO instead of CO₂ gives an answer that’s off by one oxygen atom (15.999 g/mol), and there’s no way to know from the number alone that anything went wrong.
Parentheses errors. Al₂(SO₄)₃ contains 2 aluminium atoms, 3 sulfur atoms, and 12 oxygen atoms (4 inside the brackets × 3 outside). Missing the parenthesis multiplier gives 8 oxygens instead of 12. The molar mass drops from 342.15 g/mol to 294.15 g/mol — a 16% error.
Unit confusion: grams vs milligrams. The formula uses mass in grams. If your balance reads in milligrams (common in analytical chemistry), divide by 1,000 first. 500 mg = 0.5 g, not 500 g. Skip the conversion and your mole count is off by a factor of 1,000.
Wrong direction: dividing vs multiplying. Grams to moles means dividing by molar mass. Moles to grams means multiplying by molar mass. These directions get swapped on a significant number of student worksheets — write them down separately if you need to keep them straight.
Using anhydrous molar mass for a hydrated compound. If the solid in front of you is the blue hydrated form of copper sulfate, its molar mass is 249.68 g/mol — not 159.60 g/mol. Using the anhydrous value gives a mole count that’s 56% too high.
Converting the direction wrong (multiplying instead of dividing, or vice versa) produces answers that are off by the square of the molar mass — errors in the thousands for large molecules. If your mole answer looks unreasonably large or small, check which direction you went first.
Hydrates: the extra water that counts
Hydrated salts have water molecules chemically bound into the crystal structure. When you weigh out copper sulfate pentahydrate (the blue solid in most school chemistry labs), you’re weighing CuSO₄·5H₂O. The “·5H₂O” part is not an impurity — it’s part of the compound. Those 5 water molecules per formula unit add 5 × 18.015 = 90.075 g/mol to the molar mass.
| Hydrate | Anhydrous molar mass | Hydrated molar mass | Difference |
|---|---|---|---|
| CuSO₄·5H₂O | 159.60 g/mol | 249.68 g/mol | +56.4% |
| Na₂SO₄·10H₂O | 142.04 g/mol | 322.19 g/mol | +126.8% |
| MgSO₄·7H₂O (Epsom salt) | 120.36 g/mol | 246.47 g/mol | +104.8% |
| Na₂CO₃·10H₂O (washing soda) | 105.99 g/mol | 286.14 g/mol | +170.0% |
Using the anhydrous molar mass for a hydrated compound gives a calculation that’s off by 57% to 170%. This is the single largest source of error in students preparing solutions from hydrated salts.
Significant figures and when they matter
A molar mass of 18.015 g/mol has five significant figures. If your mass measurement is 36 g (two significant figures), your answer should be reported to two significant figures: 2.0 mol, not 1.999 mol.
The rule: your answer can’t be more precise than your least precise input.
In practice, homework problems often use exact round numbers (36 g of H₂O) and expect a round answer (2 mol). Lab work uses the actual precision of your balance (typically 4 decimal places for analytical balances). Exam mark schemes usually specify significant figures explicitly.
Don’t round intermediate values. Calculate molar mass with full atomic masses (H = 1.008, not 1), then round only the final answer to the appropriate number of significant figures. Each premature rounding introduces a small error that compounds through the calculation.
Limitation: standard atomic masses vs isotope-specific masses
The calculator uses standard atomic weights from the IUPAC periodic table. These are weighted averages across all naturally occurring isotopes of each element.
Hydrogen’s standard atomic weight is 1.008, which reflects the fact that natural hydrogen is 99.985% ¹H (mass 1.00783) and 0.015% deuterium (mass 2.01410).
For most chemistry, standard atomic weights are exactly what you want. But for specialized applications — mass spectrometry, isotope labelling, carbon-13 NMR, radioactive decay calculations — the standard masses don’t apply. Those fields use monoisotopic masses: the mass of the most abundant single isotope, not the weighted average. If you’re working in one of those areas, this calculator will give you the wrong molar mass.
The standard atomic masses in every general chemistry course are weighted averages. They're right for bench chemistry. They're wrong for mass spectrometry. Know which one you need before you calculate.
What to do with the moles result
Number of molecules — multiply moles by 6.022 × 10²³. Two moles of water contains 1.204 × 10²⁴ molecules.
Stoichiometry — apply the mole ratio from your balanced equation to find how many moles of reactant you need or how much product you’ll produce.
Molarity — if you’re dissolving the substance in solution, moles ÷ volume in litres = molarity (mol/L). Two moles of NaCl dissolved in 1 litre of solution = 2M.
Percent yield — actual moles produced ÷ theoretical moles expected × 100%. Both numbers need to be in moles before you can compare them fairly.
Limiting reagent — convert grams of each reactant to moles, divide each by its stoichiometric coefficient, and the smallest result identifies the limiting reagent.
Every one of these starts with the grams-to-moles step. Get that right and the rest of the calculation follows the rules.
Your conversion is correct when the molar mass shown in the output matches what you’d calculate manually from the periodic table — element by element, subscript by subscript. The element breakdown the calculator displays is there for exactly this purpose: verify it before you use the mole count downstream.
The bottom line
Grams to moles is one division. The difficulty is in assembling the right molar mass before you divide — getting the formula right, parsing the parentheses correctly, including the hydrate water if it’s there, and using the right atomic masses.
The calculator handles the molar mass assembly automatically. Your job is entering the formula correctly. Double-check subscripts, include parentheses where they belong, and match the formula to the actual compound you’re working with — hydrated or anhydrous.
Get those inputs right and the output is reliable for every downstream calculation that depends on it.
Frequently Asked Questions
What is the formula for grams to moles?
moles = mass (g) ÷ molar mass (g/mol). The molar mass is calculated by summing the atomic masses of all atoms in the formula, weighted by their subscript counts.
How do I find the molar mass of a compound?
Add the atomic masses of every atom in the formula. For H₂O: (2 × 1.008) + (1 × 15.999) = 18.015 g/mol. This calculator does it automatically when you enter a formula.
Can I enter formulas with parentheses?
Yes — Ca(OH)₂, Fe₂(SO₄)₃, Al₂(SO₄)₃, and nested parentheses are all supported. The parser handles brackets [ ] too.
What happens with hydrates like CuSO4·5H2O?
Enter the dot as a multiplication: CuSO4(H2O)5. The calculator will expand the parentheses correctly and include all water molecules.
How do I convert moles back to grams?
Multiply moles by molar mass: grams = moles × molar mass (g/mol). This is the reverse of the grams-to-moles formula. Example: 2 moles of CO₂ (molar mass 44.01 g/mol) = 2 × 44.01 = 88.02 g.
What is the molar mass of water (H₂O)?
H₂O: (2 × 1.008) + (1 × 15.999) = 2.016 + 15.999 = 18.015 g/mol. This means 18.015 grams of water contains exactly 1 mole (6.022 × 10²³ molecules).
What is the molar mass of NaCl?
NaCl: Na (22.990) + Cl (35.45) = 58.44 g/mol. So 58.44 grams of table salt contains 1 mole of NaCl, which is 6.022 × 10²³ formula units of sodium chloride.
How many grams is 1 mole of CO₂?
CO₂ molar mass: C (12.011) + 2 × O (15.999) = 12.011 + 31.998 = 44.009 g/mol. So 1 mole of carbon dioxide weighs 44.009 grams. At STP, this occupies 22.4 litres as a gas.
How do I calculate the number of molecules from grams?
First convert grams to moles (moles = mass / molar mass), then multiply by Avogadro's number (6.022 × 10²³). Example: 18.015 g of water → 1 mole → 1 × 6.022 × 10²³ = 6.022 × 10²³ water molecules.
What is stoichiometry and how does it use mole conversion?
Stoichiometry uses the mole ratios from a balanced chemical equation to calculate reactant and product quantities. Since equations use moles, you must first convert any gram quantities to moles, apply the mole ratio, then convert back to grams. Example: 2H₂ + O₂ → 2H₂O. To find how many grams of O₂ react with 4 g of H₂: 4/2.016 = 1.98 mol H₂ → 0.99 mol O₂ → 0.99 × 32 = 31.7 g O₂.
Related Calculators
Atoms to Moles Calculator
Convert a number of atoms to moles using Avogadro's number (6.022 × 10²³). Supports scientific notation input.
Mole Calculator
Calculate moles from mass and molar mass, number of atoms/molecules, or gas volume at STP. Three modes via the "Calculate From" selector.
Molarity Calculator
Calculate the molarity (molar concentration) of a solution — moles of solute per litre. Enter mass of solute, its molar mass, and volume of solution.
Molar Mass Calculator
Calculate the molar mass of any chemical compound by entering its formula. Shows atomic mass breakdown for each element.
Liters to Moles Calculator
Convert gas volume (liters) to moles using the ideal gas law. Choose STP, SATP, or enter custom pressure and temperature.
Theoretical Yield Calculator
Calculate the theoretical yield of a product from reactant mass, molar masses, and the stoichiometric molar ratio.