Grams to Moles Calculator
Type any formula and a mass to get moles with steps: molar mass worked out element by element, moles, molecules and atoms, a mole map of your route, and four charts. It also converts moles to grams, particles to grams, and finds molar mass from grams and moles.
⚡ 0. Quick Answer
A grams to moles calculator divides the mass of a substance by its molar mass. For 25.0 g of water, the molar mass of H2O is 2 × 1.008 + 15.999 = 18.015 g/mol, so:
Rule of thumb: grams to moles, divide by M; moles to grams, multiply by M. Keep the answer to the significant figures of the mass you measured: 25.0 g has 3, so the answer is 1.39 mol.
🔑 Key Takeaways
- A grams to moles calculator uses one formula, n = m ÷ M, where M is the molar mass in g/mol.
- The molar mass comes from the formula: water is 2 × 1.008 + 15.999 = 18.015 g/mol, so 25.0 g of water is 1.39 mol.
- Moles to grams is the reverse: 2.50 mol of CO2 × 44.009 g/mol = 1.10 × 102 g.
- Multiply moles by Avogadro’s constant, 6.022 140 76 × 1023 mol−1 (exact), to count molecules or atoms.
- Round only the final answer, to the significant figures of the measured mass: 25.0 g gives 3 s.f., so 1.38773… mol becomes 1.39 mol.
📚 1. What Is a Grams to Moles Calculator?
A grams to moles calculator converts a mass you can weigh on a balance into an amount of substance, measured in moles (mol). One mole is exactly 6.022 140 76 × 1023 particles. Since the 2019 redefinition of the SI, this number, Avogadro’s constant, is fixed by definition (Marquardt et al., 2018; Newell et al., 2018).
The bridge between grams and moles is the molar mass (M, in g/mol): the mass of one mole. You find it by adding the atomic weights of every atom in the formula. Then:
A worked one-liner: how many moles are in 10.0 g of sodium chloride? M(NaCl) = 22.990 + 35.45 = 58.44 g/mol, so n = 10.0 ÷ 58.44 = 0.171 mol.
Who uses it: CBSE and ICSE students meet the mole concept in NCERT Class 9 and Class 11; JEE and NEET papers use it in almost every physical chemistry question; IGCSE, GCSE, A level, AP Chemistry and IB students use it for every reacting-mass calculation. Pharmacists convert milligrams of a drug to millimoles, lab technicians weigh out reagents for a given number of moles, and teachers build answer keys for a grams to moles calculations worksheet.
| Quantity | Symbol and unit | What it measures | Water example |
|---|---|---|---|
| Mass | m, g | How heavy the sample is | 25.0 g |
| Molar mass | M, g/mol | Mass of one mole of the substance | 18.015 g/mol |
| Amount of substance | n, mol | How many particles, counted in moles | 1.39 mol |
| Number of particles | N, no unit | The actual count of molecules or atoms | 8.36 × 1023 molecules |
| Relative molecular mass | Mr, no unit | Same number as M, without the unit | 18.015 |
Students often say “the moles” as if a mole were a thing. It is a unit, like a dozen: 1.39 mol of water is the amount, and mol is its unit (Pekdağ & Azizoğlu, 2013; Furió et al., 2002).
How accurate is this grams to moles calculator?
Molar masses use the CIAAW 2024 standard atomic weights for all 118 elements (Prohaska et al., 2022), or rounded exam values if you choose them. The calculator keeps full precision in every step and only rounds the final answer, to the significant figures of the number you typed. It then substitutes the answer back: n × M must give the mass, N ÷ NA must give the moles, and the element masses must add up to the total. Only then does it show the Verified badge. The R and Python scripts in Sections 10 and 11 give the same 18.015 g/mol and 1.39 mol for the headline example.
| What you get | Why it matters |
|---|---|
| Molar mass worked out element by element | The step most textbook answers skip, and the one marks are given for |
| Five directions: g → mol, mol → g, g → particles, particles → g, molar mass | One tool for every mole-concept question |
| mg, µg, kg, lb, oz and mmol, µmol | Drug doses, trace analysis and industrial amounts without hand conversion |
| Significant figures from your data | The rounding exam markers expect, with the full value shown too |
| Moles, grams and atoms of each element | Answers “how many moles of oxygen atoms” questions |
| Purity and a typed-in molar mass | Real reagents are 95 to 99.9% pure; some questions give M instead of a formula |
| Batch mode with CSV export and a shareable link | A whole worksheet in one go, or one problem sent to a classmate |
🧮 2. Enter Your Problem in the Grams to Moles Calculator
What do you want to find?
Common compounds (tap one to fill the formula box)
Type it like this: H2O, Ca(OH)2, Al2(SO4)3, K4[Fe(CN)6], hydrates as CuSO4.5H2O, ions as SO4^2-. Capitals matter: Co is cobalt, CO is carbon monoxide.
Write powers of ten as 3.01e23 or 3.01 x 10^23. Trailing zeros count: type 25.0, not 25, if your balance read 25.0 g. No formula? Leave it empty and type the molar mass instead. For an impure sample, type its purity (for example 98) and only the pure part is converted. In Grams → moles mode, choose mmol or µmol in the Amount box to get the answer in those units.
Press Enter in any box to calculate. Nothing is calculated until you press the button.
The unit sets the direction: a mass unit (g, mg, µg, kg, lb, oz) converts to moles; a mole unit (mol, mmol, µmol) converts to grams; particles converts a count to grams. The atomic-weight setting from the One problem tab is used.
📊 3. Grams to Moles Calculator Results with Step-by-Step Working
🧠 4. What Does Your Grams to Moles Answer Mean?
4.1 What a number of moles actually means
A mole is a counting unit, like a dozen, but for particles too small to count one by one. 1.39 mol of water means 1.39 × 6.022 × 1023 = 8.36 × 1023 water molecules. Chemists weigh instead of count because a balance is fast and accurate, and the molar mass turns grams into a count.
4.2 Why heavy formulas give fewer moles per gram
Moles per gram is 1 ÷ M. Hydrogen gas (M = 2.016 g/mol) gives 0.496 mol per gram; gold (M = 196.97 g/mol) gives only 0.00508 mol per gram. The same 1.00 g of the two holds about 98 times more H2 molecules than gold atoms. Chart 4 in the results shows this for your own mass.
4.3 Is your answer a sensible size?
| Amount | Typical situation | Example |
|---|---|---|
| Below 0.001 mol (1 mmol) | Drug doses, trace analysis | 325 mg aspirin = 1.80 mmol |
| 0.001 to 0.5 mol | School and university lab work | 10.0 g NaCl = 0.171 mol |
| 0.5 to 20 mol | Large lab batches, kitchen amounts | 1 litre of water (1000 g) = 55.5 mol |
| Above 20 mol | Pilot plant and industry | 1 tonne of CaCO3 = 9.99 × 103 mol |
If a school problem gives you 104 mol or 10−9 mol, check the units first: a mass in mg typed as g is a factor of 1000 out.
4.4 Molecules, formula units, atoms and ions
The calculator names the particle for you. Covalent substances such as H2O and CO2 are made of molecules. Ionic compounds such as NaCl and CaCO3 have no separate molecules, so one “particle” is a formula unit. A single element written as one symbol (Au, Fe, C) counts atoms. An ion such as SO42− counts ions. Always state which particle you mean: 1 mol of O2 is 6.022 × 1023 molecules but 1.204 × 1024 oxygen atoms.
4.5 Significant figures: why 1.39 and not 1.3877
Your answer can only be as precise as your weakest measurement. A mass of 25.0 g has three significant figures; the molar mass 18.015 g/mol has five; Avogadro’s constant is exact. The mass limits the answer to three, so 1.38773… mol is written 1.39 mol. The calculator keeps every digit until the last step, so rounding never builds up. Type 25.00 if your balance reads to 0.01 g, and you get 1.388 mol.
4.6 Which atomic weights you use changes the last digit
With CIAAW 2024 weights, M(H2O) = 18.015 g/mol; with rounded exam values (H = 1, O = 16), M = 18 g/mol. For 25.0 g that gives 1.3877 and 1.3889 mol, both 1.39 mol to three significant figures. The difference shows up for heavy molecules or when you need four or more figures, so use the values your exam or lab manual gives.
4.7 The gas volume and molarity lines
The results table also shows the volume your moles would fill as an ideal gas, and the molarity if you dissolved them in a volume you type. The gas line is a reference only: water is a liquid at room temperature, so 1.39 mol of liquid water fills 25 mL, not 31.5 L. State which STP you use, because 0 °C and 1 bar (22.711 L/mol) and 0 °C and 1 atm (22.414 L/mol) differ by 1.3%.
4.8 A field note on why the molar mass step deserves the most care
In checking hundreds of student answers, nearly every wrong grams to moles result traces back to the molar mass, not the division. The usual culprits are a missed bracket (Ca(OH)2 has two O atoms, not one), forgotten water of crystallisation in a hydrate, and Co typed for CO. Research on the mole concept finds the same thing: students can run the formula n = m ÷ M but struggle to link molar mass to what is in the formula (Staver & Lumpe, 1995; Furió et al., 2002). That is why this calculator writes the molar mass out element by element before it divides.
4.9 How this links to the next topic
Grams to moles is step one of stoichiometry. With moles in hand you use the mole ratio from a balanced equation to find the moles of a product, then multiply by its molar mass to get grams. The same n = m ÷ M runs through limiting reagent, theoretical yield, percent yield, empirical formula and molarity calculations.
✍ 5. How to Write a Grams to Moles Answer
📌 Conventions examiners look for
- Show the molar mass sum first, with each atomic weight.
- Write the formula n = m ÷ M, then substitute with units.
- Give the final answer with a unit and the right significant figures.
- Keep full precision in the middle; round once at the end.
📌 Conventions
- The unit symbol is mol (no s): 2 mol, not 2 mols.
- Use scientific notation for very large or small numbers: 8.36 × 1023.
📌 Conventions
- Give the mass you weighed and the balance resolution.
- Name the atomic-weight source if you quote a molar mass.
- For hydrates, say whether the water of crystallisation was included.
📌 Conventions
- Accept answers that differ only in the last digit if the student used rounded atomic weights.
- Use the Batch tab to make a whole worksheet answer key.
📌 Conventions
- Write subscripts as plain digits: H2O, CO2.
- Write powers of ten as e: 8.36e23.
∑ 6. Formulas Used by the Grams to Moles Calculator
🔀 7. How Do You Convert Grams to Moles? Flowchart, Step by Step
This flowchart shows how to calculate moles from grams, on the same example used in the Excel, R, Python and by-hand sections: how many moles are in 25.0 g of water?
Check any box yourself: the Excel sheet in Section 9, the R script in Section 10 and the Python script in Section 11 all return 18.015 g/mol and 1.39 mol for this problem.
📝 8. How to Use This Grams to Moles Calculator
- Choose what you want to find. Pick grams to moles, moles to grams, grams to atoms or molecules, atoms or molecules to grams, or find the molar mass.
- Type the chemical formula. Write it as H2O, NaCl or Ca(OH)2, or tap a common compound. No formula? Leave it empty and type the molar mass in g/mol instead.
- Check the capital letters. Element symbols start with a capital and any second letter is small: Co is cobalt, CO is carbon monoxide.
- Enter the mass or the moles. Type the number exactly as measured, including trailing zeros such as 25.0, because they set the significant figures.
- Pick the unit. Choose g, mg, µg, kg, lb or oz for mass, and mol, mmol or µmol for amount. The calculator converts for you.
- Choose the atomic weights and purity. Keep CIAAW 2024 values or switch to rounded exam values, and type a purity such as 98% for an impure sample.
- Press Convert. Nothing is calculated before you press it, and changing any input clears the old answer.
- Read the answer and the molar mass table. The Verified badge means the answer was substituted back and matched.
- Follow the steps and the mole map. Copy the working into your notebook in the same order.
- Copy, share or batch. Copy the answer, share a link to the problem, download a report, or convert a whole worksheet on the Batch tab.
📈 9. How to Calculate Grams to Moles in Excel
Excel cannot read a chemical formula, so you lay the formula out as a small table: one row per element with its count and atomic weight. SUMPRODUCT gives the molar mass, and a single division gives the moles. The sheet below uses the headline problem, 25.0 g of water, so it must return 18.015 g/mol and 1.39 mol, the same as the grams to moles calculator above.
=F2/D4. That is grams to moles. Moles to grams is =G2*D4.9.1 The functions you need
| You want | Excel formula | Note |
|---|---|---|
| Molar mass | =SUMPRODUCT(B2:B3,C2:C3) | Counts in column B, atomic weights in column C |
| Grams to moles | =F2/D4 | Mass divided by molar mass |
| Moles to grams | =G2*D4 | Moles times molar mass |
| Molecules | =G2*6.02214076E+23 | Type E+23, not 10^23 |
| Round to 3 significant figures | =ROUND(G2,3-1-INT(LOG10(ABS(G2)))) | Change the 3 for other s.f. |
| Milligrams to millimoles | =F2/D4 with F2 in mg | mg ÷ g/mol gives mmol directly |
| Molar mass from data | =F2/G2 | Grams divided by moles |
25.0 g into a cell, Excel stores text and every formula that uses it returns #VALUE!. Put the number in one cell and the unit in the column header.9.2 Step by step
1 Lay out the formula as a table
One row per element: symbol in A, number of atoms in B, atomic weight in C. In D2 type =B2*C2 and fill down for each subtotal.
Water has 2 H and 1 O; subtotals 2.016 and 15.999 g/mol.
2 Add up the molar mass with SUMPRODUCT
In D4 type the formula. It multiplies each count by its weight and adds the results.
=SUMPRODUCT(B2:B3,C2:C3)
The molar mass of water is 18.015 g/mol.
3 Divide the mass by the molar mass
Put the mass in F2 and divide by D4. Add the rounded answer and the number of molecules next to it.
=F2/D4 =ROUND(G2,3-1-INT(LOG10(ABS(G2)))) =G2*6.02214076E+23
25.0 g gives 1.38773 mol, rounded to 1.39 mol, or 8.36E+23 molecules.
4 Convert a whole list at once
For a worksheet, put each compound’s molar mass in column B and its mass in column C. In D2 type =C2/B2 and fill down.
Five compounds converted in one column: 2.00, 0.100, 0.500, 0.250, 0.0250 mol.
9.3 Awkward cases
- Brackets. Count the atoms before typing: Ca(OH)2 is 1 Ca, 2 O, 2 H.
- Hydrates. Add the water as extra rows: CuSO4·5H2O has 9 O and 10 H.
- Very large or small numbers. Format the cell as Scientific with 2 decimals to see 8.36E+23.
- Moles to grams. Use
=moles*molar_mass; the table layout is the same.
9.4 Why your Excel answer might differ from R, Python or this page
| Situation | What happens | Fix |
|---|---|---|
| Last digit differs | Different atomic weights (18 vs 18.015 for water) | Use the same weights; both round to 1.39 mol here |
| Answer shows 1.387732 | Cell shows full precision | Use the ROUND formula or Format Cells |
| ROUND gives a different number of figures | Excel’s ROUND counts decimal places, not s.f. | Use the LOG10 version in 9.1 |
| Answer 1000 times too big | Mass typed in mg but treated as g | Divide by 1000, or label the answer mmol |
| Tool | Molar mass | Grams to moles |
|---|---|---|
| Excel / Google Sheets | =SUMPRODUCT(B2:B3,C2:C3) | =F2/D4 |
| R | sum(counts * W[names(counts)]) | mass_g / M |
| Python | sum(n * W[e] for e, n in counts.items()) | mass_g / M |
| Casio fx-991EX | 2 × 1.008 + 15.999 = | 25 ÷ Ans = |
9.5 Charting in Excel
- Select the element symbols and their subtotals (A2:A3, D2:D3).
- Insert → Charts → Bar to show which element carries most of the molar mass (Chart 1 above).
- For mass against moles, make a column of moles (0, 0.5, 1, 1.5, 2), a column
=moles*$D$4, then Insert → Scatter with Straight Lines.
9.6 Excel errors you will probably hit
| Excel shows | Why | Fix |
|---|---|---|
#DIV/0! | The molar mass cell is empty or zero | Check the SUMPRODUCT range |
#VALUE! | A unit was typed in a number cell | Keep units in the header row |
#NUM! | LOG10 of zero or a negative mass in the s.f. formula | The mass must be positive |
6.02E+23 shows as 6.02214E+23 only after formatting | Display format | Format Cells → Scientific |
📈 10. How to Calculate Grams to Moles in R
This base R script reads a formula, works out the molar mass element by element (brackets and hydrates included), converts grams to moles, molecules and atoms, checks the answer by substituting back, and saves one 300 dpi chart. For 25.0 g of water it prints 18.015 g/mol and 1.39 mol, matching the grams to moles calculator on this page.
Rscript grams_to_moles.R. Change only the formula, mass_g and sig_figs lines.10.1 The complete script
R, base only, saves grams_to_moles.png
# ============================================================
# Grams to moles in R: molar mass from the formula, then n = m / M
# StatsUnlock - https://statsunlock.com/grams-to-moles-calculator/
# Base R only. No packages to install.
# ============================================================
# ---- 1. Your problem -------------------------------------------
formula <- "H2O" # brackets and hydrates work: Ca(OH)2, CuSO4.5H2O
mass_g <- 25.0 # grams (convert mg to g first: 325 mg = 0.325 g)
sig_figs <- 3 # significant figures in your mass
N_A <- 6.02214076e23 # Avogadro constant, mol^-1 (exact)
# CIAAW 2024 standard atomic weights (g/mol); add any element you need
W <- c(H = 1.008, Li = 6.94, C = 12.011, N = 14.007, O = 15.999, F = 18.998,
Na = 22.990, Mg = 24.305, Al = 26.982, Si = 28.085, P = 30.974,
S = 32.06, Cl = 35.45, K = 39.098, Ca = 40.078, Mn = 54.938,
Fe = 55.845, Cu = 63.546, Zn = 65.38, Br = 79.904, Ag = 107.87,
I = 126.90, Ba = 137.33, Au = 196.97, Pb = 207.2)
# Count atoms, multiplying through brackets and the hydrate dot
parse_formula <- function(f) {
total <- c()
parts <- strsplit(f, "[.*]")[[1]]
for (i in seq_along(parts)) {
part <- parts[i]; mult <- 1
if (i > 1 && grepl("^[0-9]+", part)) {
mult <- as.numeric(sub("^([0-9]+).*", "\\1", part))
part <- sub("^[0-9]+", "", part)
}
tok <- regmatches(part, gregexpr("[A-Z][a-z]?|[0-9]+|[][()]", part))[[1]]
stack <- list(numeric(0)); j <- 1
while (j <= length(tok)) {
t <- tok[j]; j <- j + 1
if (t %in% c("(", "[")) { stack[[length(stack) + 1]] <- numeric(0); next }
n <- 1
if (j <= length(tok) && grepl("^[0-9]+$", tok[j])) { n <- as.numeric(tok[j]); j <- j + 1 }
top <- length(stack)
if (t %in% c(")", "]")) {
inner <- stack[[top]] * n; stack[[top]] <- NULL; top <- top - 1
for (k in names(inner)) stack[[top]][k] <- sum(stack[[top]][k], inner[k], na.rm = TRUE)
} else {
stack[[top]][t] <- sum(stack[[top]][t], n, na.rm = TRUE)
}
}
for (k in names(stack[[1]])) total[k] <- sum(total[k], stack[[1]][k] * mult, na.rm = TRUE)
}
total
}
# ---- 2. Molar mass ---------------------------------------------
counts <- parse_formula(formula)
if (any(!names(counts) %in% names(W))) stop("Add the atomic weight of ", paste(setdiff(names(counts), names(W)), collapse = ", "))
sub_mass <- counts * W[names(counts)]
M <- sum(sub_mass)
print(data.frame(element = names(counts), atoms = as.vector(counts),
subtotal = round(as.vector(sub_mass), 3),
percent = round(100 * as.vector(sub_mass) / M, 2)))
cat(sprintf("Molar mass M(%s) = %.3f g/mol\n", formula, M))
# ---- 3. Grams to moles, moles to particles ---------------------
if (mass_g <= 0) stop("Mass must be greater than zero")
n <- mass_g / M
N <- n * N_A
cat(sprintf("Moles n = m / M = %g g / %.3f g/mol = %s mol\n", mass_g, M, signif(n, sig_figs)))
cat(sprintf("Particles N = n x N_A = %s\n", format(signif(N, sig_figs), scientific = TRUE)))
cat(sprintf("Atoms in total = %s\n", format(signif(N * sum(counts), sig_figs), scientific = TRUE)))
# ---- 4. Verify: substitute back ---------------------------------
stopifnot(abs(n * M - mass_g) < 1e-9 * mass_g)
cat("Verdict: Verified, n x M gives back", round(n * M, 6), "g\n")
# ---- 5. One 300 dpi figure: moles of each element's atoms --------
png("grams_to_moles.png", width = 2100, height = 1350, res = 300)
par(mar = c(4.5, 5, 3, 1))
barplot(n * counts, names.arg = names(counts), las = 1, border = NA,
col = c("#2563eb", "#ea580c", "#16a34a", "#9333ea", "#0d9488")[seq_along(counts)],
xlab = "Element", ylab = "Moles of atoms (mol)",
main = sprintf("%g g of %s = %s mol", mass_g, formula, signif(n, sig_figs)))
invisible(dev.off())
cat("Saved grams_to_moles.png\n")Output: Molar mass M(H2O) = 18.015 g/mol, n = m / M = 25 g / 18.015 g/mol = 1.39 mol, Particles N = 8.36e+23, Verdict: Verified.
10.2 R traps
signif()rounds to significant figures;round()rounds to decimal places. Usesignif(n, 3)for 1.39.- R prints 25.0 as 25, dropping the trailing zero. Keep track of significant figures yourself with
sig_figs. log()is the natural log; uselog10()if you build your own s.f. rounding.- Named vectors must match:
W[names(counts)]picks the right weight for each element.
10.3 What each part does
| Part | What it does |
|---|---|
parse_formula() | Counts atoms, multiplying through brackets and the hydrate dot |
sum(counts * W[...]) | The molar mass, M = Σ n × Ar |
n <- mass_g / M | Grams to moles |
N <- n * N_A | Moles to molecules |
stopifnot(...) | The check: n × M must give back the mass |
10.4 Using a package for element data
The script carries a small table of CIAAW atomic weights. To cover every element, the PeriodicTable package gives mass("O"); check that its values match the edition your course uses.
10.5 The figure
The script saves grams_to_moles.png at 2100 × 1350 pixels and 300 dpi: one bar per element showing the moles of its atoms in your sample (2.78 mol of H atoms and 1.39 mol of O atoms for 25.0 g of water).
🐍 11. How to Calculate Grams to Moles in Python
This script does the same job in plain Python: it parses the formula, prints the molar mass table, converts grams to moles, molecules and atoms, verifies the answer and saves a 300 dpi chart. It is the same method the grams to moles calculator runs in your browser.
Install once: pip install matplotlib
11.1 The complete script
Python, saves grams_to_moles.png
# ============================================================
# Grams to moles in Python: molar mass from the formula, then n = m / M
# StatsUnlock - https://statsunlock.com/grams-to-moles-calculator/
# pip install matplotlib
# ============================================================
import re
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
# ---- 1. Your problem -------------------------------------------
formula = "H2O" # brackets and hydrates work: Ca(OH)2, CuSO4.5H2O
mass_g = 25.0 # grams (convert mg to g first: 325 mg = 0.325 g)
sig_figs = 3 # the number of significant figures in your mass
N_A = 6.02214076e23 # Avogadro constant, mol^-1 (exact)
# CIAAW 2024 standard atomic weights (g/mol); add any element you need
W = {"H": 1.008, "Li": 6.94, "C": 12.011, "N": 14.007, "O": 15.999, "F": 18.998,
"Na": 22.990, "Mg": 24.305, "Al": 26.982, "Si": 28.085, "P": 30.974,
"S": 32.06, "Cl": 35.45, "K": 39.098, "Ca": 40.078, "Mn": 54.938,
"Fe": 55.845, "Cu": 63.546, "Zn": 65.38, "Br": 79.904, "Ag": 107.87,
"I": 126.90, "Ba": 137.33, "Au": 196.97, "Pb": 207.2}
def parse_formula(f):
"""Count atoms in a formula such as Ca(OH)2, Al2(SO4)3 or CuSO4.5H2O."""
total = {}
for i, part in enumerate(re.split(r"[.*·]", f)):
mult = 1
m = re.match(r"^(\d+)(.*)$", part)
if m and i > 0: # the 5 in CuSO4.5H2O
mult, part = int(m.group(1)), m.group(2)
tokens = re.findall(r"[A-Z][a-z]?|\d+|[()\[\]]", part)
stack, j = [{}], 0
while j < len(tokens):
t = tokens[j]; j += 1
if t in "([":
stack.append({}); continue
n = 1
if j < len(tokens) and tokens[j].isdigit():
n = int(tokens[j]); j += 1
if t in ")]": # close a bracket, multiply what is inside
for k, v in stack.pop().items():
stack[-1][k] = stack[-1].get(k, 0) + v * n
else: # an element symbol
stack[-1][t] = stack[-1].get(t, 0) + n
for k, v in stack[0].items():
total[k] = total.get(k, 0) + v * mult
return total
# ---- 2. Molar mass ---------------------------------------------
counts = parse_formula(formula)
missing = [e for e in counts if e not in W]
if missing:
raise SystemExit(f"Add the atomic weight of {missing} to W")
M = sum(n * W[e] for e, n in counts.items())
for e, n in counts.items():
print(f" {e}: {n} x {W[e]} = {n * W[e]:.3f} g/mol ({100 * n * W[e] / M:.2f}%)")
print(f"Molar mass M({formula}) = {M:.3f} g/mol")
# ---- 3. Grams to moles, moles to particles ---------------------
if mass_g <= 0:
raise SystemExit("Mass must be greater than zero")
n = mass_g / M
N = n * N_A
atoms = N * sum(counts.values())
print(f"Moles n = m / M = {mass_g} g / {M:.3f} g/mol = {n:.{sig_figs}g} mol")
print(f"Particles N = n x N_A = {N:.{sig_figs - 1}e}")
print(f"Atoms in total = {atoms:.{sig_figs - 1}e}")
# ---- 4. Verify: substitute back ---------------------------------
assert abs(n * M - mass_g) < 1e-9 * mass_g, "n x M does not give back the mass"
print("Verdict: Verified, n x M gives back", round(n * M, 6), "g")
# ---- 5. One 300 dpi figure: moles of each element's atoms --------
els = list(counts)
mol_atoms = [n * counts[e] for e in els]
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.bar(els, mol_atoms, color=["#2563eb", "#ea580c", "#16a34a", "#9333ea", "#0d9488"][:len(els)])
ax.set_xlabel("Element")
ax.set_ylabel("Moles of atoms in the sample (mol)")
ax.set_title(f"{mass_g} g of {formula} = {n:.{sig_figs}g} mol")
fig.tight_layout()
fig.savefig("grams_to_moles.png", dpi=300)
print("Saved grams_to_moles.png")Output: Molar mass M(H2O) = 18.015 g/mol, n = m / M = 25.0 g / 18.015 g/mol = 1.39 mol, Particles N = 8.36e+23, Atoms in total = 2.51e+24.
11.2 Python traps
6.02214076e23is how Python writes 6.022 × 1023;6.022*10^23is wrong because^is bitwise XOR.f"{n:.3g}"rounds to 3 significant figures;round(n, 3)rounds to 3 decimal places.round()rounds half to even, soround(0.125, 2)gives 0.12. For exam-style rounding use thedecimalmodule.- The
periodictableandmendeleevpackages may differ from CIAAW 2024 in the last digit for some elements.
11.3 Using a package
With pip install periodictable, periodictable.formula("H2O").mass returns the molar mass for any formula, and 25.0 / periodictable.formula("H2O").mass gives the moles.
11.4 What each part does
| Part | What it does |
|---|---|
parse_formula() | Counts atoms through brackets and hydrates |
M = sum(...) | Molar mass from the atomic weights |
n = mass_g / M | Grams to moles |
assert abs(n * M - mass_g) ... | The check, substituting back |
11.5 The figure
The script saves grams_to_moles.png at 300 dpi with the moles of each element’s atoms in the sample.
📋 12. Reference Tables for Grams to Moles Conversions
12.1 Atomic weights of common elements
| Element | Symbol | Standard atomic weight (CIAAW 2024) | Rounded exam value |
|---|---|---|---|
| Hydrogen | H | 1.0080 | 1 |
| Carbon | C | 12.011 | 12 |
| Nitrogen | N | 14.007 | 14 |
| Oxygen | O | 15.999 | 16 |
| Sodium | Na | 22.990 | 23 |
| Magnesium | Mg | 24.305 | 24 |
| Aluminum | Al | 26.982 | 27 |
| Phosphorus | P | 30.974 | 31 |
| Sulfur | S | 32.06 | 32 |
| Chlorine | Cl | 35.45 | 35.5 |
| Potassium | K | 39.098 | 39 |
| Calcium | Ca | 40.078 | 40 |
| Manganese | Mn | 54.938 | 55 |
| Iron | Fe | 55.845 | 56 |
| Copper | Cu | 63.546 | 63.5 |
| Zinc | Zn | 65.38 | 65 |
| Silver | Ag | 107.87 | 108 |
| Iodine | I | 126.90 | 127 |
| Barium | Ba | 137.33 | 137 |
| Gold | Au | 196.97 | 197 |
| Lead | Pb | 207.2 | 207 |
Source: CIAAW (IUPAC Commission on Isotopic Abundances and Atomic Weights), abridged standard atomic weights, 2024 edition. Dimensionless; the same number in g/mol is the molar mass of the atoms.
12.2 Molar masses of common compounds, and moles in 1 g and 10 g
Each row was computed by the same engine as the grams to moles calculator. Use it to check homework fast.
| Substance | Formula | Molar mass (g/mol) | Moles in 1.00 g | Moles in 10.0 g | Grams in 1.00 mol |
|---|---|---|---|---|---|
| Water | H2O | 18.015 | 0.0555 | 0.555 | 18.015 g |
| Carbon dioxide | CO2 | 44.009 | 0.0227 | 0.227 | 44.009 g |
| Oxygen gas | O2 | 31.998 | 0.0313 | 0.313 | 31.998 g |
| Nitrogen gas | N2 | 28.014 | 0.0357 | 0.357 | 28.014 g |
| Hydrogen gas | H2 | 2.016 | 0.496 | 4.96 | 2.016 g |
| Ammonia | NH3 | 17.031 | 0.0587 | 0.587 | 17.031 g |
| Methane | CH4 | 16.043 | 0.0623 | 0.623 | 16.043 g |
| Sodium chloride | NaCl | 58.440 | 0.0171 | 0.171 | 58.440 g |
| Sodium hydroxide | NaOH | 39.997 | 0.0250 | 0.250 | 39.997 g |
| Hydrochloric acid (HCl) | HCl | 36.458 | 0.0274 | 0.274 | 36.458 g |
| Sulfuric acid | H2SO4 | 98.072 | 0.0102 | 0.102 | 98.072 g |
| Nitric acid | HNO3 | 63.012 | 0.0159 | 0.159 | 63.012 g |
| Calcium carbonate | CaCO3 | 100.086 | 0.00999 | 0.0999 | 100.086 g |
| Sodium hydrogen carbonate (baking soda) | NaHCO3 | 84.006 | 0.0119 | 0.119 | 84.006 g |
| Calcium hydroxide | Ca(OH)2 | 74.092 | 0.0135 | 0.135 | 74.092 g |
| Glucose | C6H12O6 | 180.156 | 0.00555 | 0.0555 | 180.156 g |
| Sucrose | C12H22O11 | 342.297 | 0.00292 | 0.0292 | 342.297 g |
| Ethanol | C2H5OH | 46.069 | 0.0217 | 0.217 | 46.069 g |
| Copper(II) sulfate pentahydrate | CuSO4·5H2O | 249.677 | 0.00401 | 0.0401 | 249.677 g |
| Potassium permanganate | KMnO4 | 158.032 | 0.00633 | 0.0633 | 158.032 g |
| Aspirin | C9H8O4 | 180.159 | 0.00555 | 0.0555 | 180.159 g |
| Caffeine | C8H10N4O2 | 194.194 | 0.00515 | 0.0515 | 194.194 g |
12.3 Mass and amount units
| Unit | In grams or moles | Use it for |
|---|---|---|
| 1 kg | 1000 g | Industrial and bulk amounts |
| 1 mg | 0.001 g | Drug doses, small lab samples |
| 1 µg | 10−6 g | Trace analysis |
| 1 lb | 453.592 37 g (exact) | US recipes and fertiliser bags |
| 1 oz | 28.349 523 125 g (exact) | US labels |
| 1 mmol | 0.001 mol | mg ÷ g/mol gives mmol |
| 1 µmol | 10−6 mol | µg ÷ g/mol gives µmol |
12.4 Molar volume of an ideal gas at different reference conditions
| Condition | Temperature | Pressure | Molar volume Vm |
|---|---|---|---|
| STP (IUPAC, since 1982) | 0 °C (273.15 K) | 100 kPa (1 bar) | 22.711 L/mol |
| STP (older texts, CBSE) | 0 °C (273.15 K) | 101.325 kPa (1 atm) | 22.414 L/mol |
| SATP | 25 °C (298.15 K) | 100 kPa (1 bar) | 24.790 L/mol |
| RTP (GCSE, IGCSE) | about 20 to 25 °C | about 1 atm | 24.0 dm3/mol (agreed value) |
Vm = RT ÷ P with R = 8.314 462 618 J mol−1 K−1 (exact). CBSE and older textbooks use 22.4 L at 0 °C and 1 atm; IUPAC STP since 1982 is 0 °C and 1 bar. Valid only for gases that behave ideally.
12.5 Significant figure rules for grams to moles
| Number typed | Significant figures | Why |
|---|---|---|
| 25.0 | 3 | The trailing zero after a decimal point counts |
| 0.00250 | 3 | Leading zeros never count |
| 2.50 × 10−3 | 3 | Only the digits before × 10 count |
| 100 | 1 (ambiguous) | Write 100. or 1.00 × 102 to show 3 |
| 18.015 g/mol | Not limiting | Looked-up constants carry more figures than your data |
| 6.022 140 76 × 1023 | Exact | Fixed by the 2019 SI definition |
12.6 Grams to moles practice: 25 worked conversions with answers
A grams to moles calculations worksheet with its answer key, every line checked by the calculator engine. Cover the last two columns and try them first.
Free printable grams to moles worksheet with answers.
| # | Question | Molar mass | Working | Answer |
|---|---|---|---|---|
| 1 | How many moles are in 36.0 g of H2O? | 18.015 g/mol | 36.0 g ÷ 18.015 g/mol | 2.00 mol |
| 2 | How many moles are in 29.22 g of NaCl? | 58.440 g/mol | 29.22 g ÷ 58.440 g/mol | 0.5000 mol |
| 3 | How many moles are in 11.0 g of CO2? | 44.009 g/mol | 11.0 g ÷ 44.009 g/mol | 0.250 mol |
| 4 | How many moles are in 8.00 g of O2? | 31.998 g/mol | 8.00 g ÷ 31.998 g/mol | 0.250 mol |
| 5 | How many moles are in 4.00 g of CH4? | 16.043 g/mol | 4.00 g ÷ 16.043 g/mol | 0.249 mol |
| 6 | How many moles are in 20.0 g of NaOH? | 39.997 g/mol | 20.0 g ÷ 39.997 g/mol | 0.500 mol |
| 7 | How many moles are in 50.0 g of CaCO3? | 100.086 g/mol | 50.0 g ÷ 100.086 g/mol | 0.500 mol |
| 8 | How many moles are in 49.0 g of H2SO4? | 98.072 g/mol | 49.0 g ÷ 98.072 g/mol | 0.500 mol |
| 9 | How many moles are in 90.0 g of C6H12O6? | 180.156 g/mol | 90.0 g ÷ 180.156 g/mol | 0.500 mol |
| 10 | How many moles are in 1.70 g of NH3? | 17.031 g/mol | 1.70 g ÷ 17.031 g/mol | 0.0998 mol |
| 11 | How many moles are in 3.16 g of KMnO4? | 158.032 g/mol | 3.16 g ÷ 158.032 g/mol | 0.0200 mol |
| 12 | How many moles are in 7.41 g of Ca(OH)2? | 74.092 g/mol | 7.41 g ÷ 74.092 g/mol | 0.100 mol |
| 13 | How many moles are in 24.97 g of CuSO4·5H2O? | 249.677 g/mol | 24.97 g ÷ 249.677 g/mol | 0.1000 mol |
| 14 | How many millimoles are in 500.0 mg of C9H8O4? | 180.159 g/mol | 500.0 mg ÷ 180.159 g/mol | 2.775 mmol |
| 15 | How many moles are in 5.585 g of Fe? | 55.845 g/mol | 5.585 g ÷ 55.845 g/mol | 0.1000 mol |
| 16 | What is the mass of 0.500 mol of H2O? | 18.015 g/mol | 0.500 mol × 18.015 g/mol | 9.01 g |
| 17 | What is the mass of 0.250 mol of NaCl? | 58.440 g/mol | 0.250 mol × 58.440 g/mol | 14.6 g |
| 18 | What is the mass of 3.00 mol of CO2? | 44.009 g/mol | 3.00 mol × 44.009 g/mol | 132 g |
| 19 | What is the mass of 0.100 mol of H2SO4? | 98.072 g/mol | 0.100 mol × 98.072 g/mol | 9.81 g |
| 20 | What is the mass of 2.00 mol of C2H5OH? | 46.069 g/mol | 2.00 mol × 46.069 g/mol | 92.1 g |
| 21 | What is the mass of 0.0500 mol of NaHCO3? | 84.006 g/mol | 0.0500 mol × 84.006 g/mol | 4.20 g |
| 22 | What is the mass of 0.0200 mol of Al2(SO4)3? | 342.132 g/mol | 0.0200 mol × 342.132 g/mol | 6.84 g |
| 23 | How many molecules are in 9.00 g of H2O? | 18.015 g/mol | (9.00 ÷ 18.015) × 6.022 × 1023 | 3.01 × 1023 molecules |
| 24 | How many atoms are in 1.00 g of Fe? | 55.845 g/mol | (1.00 ÷ 55.845) × 6.022 × 1023 | 1.08 × 1022 atoms |
| 25 | How many molecules are in 4.40 g of CO2? | 44.009 g/mol | (4.40 ÷ 44.009) × 6.022 × 1023 | 6.02 × 1022 molecules |
📈 13. Grams to Moles Calculator Example Results
Eight examples run through the grams to moles calculator, from a textbook question to a trap that costs marks. Each figure is drawn from the computed numbers: the bar lengths are the moles of each element’s atoms in the sample.
Moles in 36.0 g of water
The cleanest grams to moles question there is.
A beaker holds 36.0 g of water. How many moles is that, and how many hydrogen atoms?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| H (Hydrogen) | 2 | 1.008 | 2.016 | 4.00 mol |
| O (Oxygen) | 1 | 15.999 | 15.999 | 2.00 mol |
| Molar mass | 18.015 | 2.00 mol H2O |
What it means: M(H2O) = 18.015 g/mol, so 36.0 ÷ 18.015 = 1.9983 mol, or 2.00 mol to three significant figures. Each molecule has two H atoms, so the sample holds 4.00 mol of hydrogen atoms.
How to write it: n(H2O) = 36.0 g ÷ 18.015 g/mol = 2.00 mol
Moles in 4.6 g of sodium
The NCERT favourite, with an element.
Find the number of moles in 4.6 g of sodium (Na = 23).
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| Na (Sodium) | 1 | 22.99 | 22.990 | 0.20 mol |
| Molar mass | 22.990 | 0.20 mol Na |
What it means: With the exam value Na = 23, n = 4.6 ÷ 23 = 0.20 mol. With CIAAW weights, 4.6 ÷ 22.990 = 0.2001 mol, still 0.20 mol to two significant figures. Two significant figures because 4.6 has two.
How to write it: n(Na) = 4.6 g ÷ 23 g/mol = 0.20 mol
5.00 g of blue copper sulfate
The water of crystallisation is part of the molar mass.
How many moles of CuSO4·5H2O are in 5.00 g of the blue crystals?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| Cu (Copper) | 1 | 63.546 | 63.546 | 0.0200 mol |
| S (Sulfur) | 1 | 32.06 | 32.060 | 0.0200 mol |
| O (Oxygen) | 9 | 15.999 | 143.991 | 0.180 mol |
| H (Hydrogen) | 10 | 1.008 | 10.080 | 0.200 mol |
| Molar mass | 249.677 | 0.0200 mol CuSO4·5H2O |
What it means: M = 159.602 + 5 × 18.015 = 249.677 g/mol, so n = 5.00 ÷ 249.677 = 0.0200 mol. Leaving out the water gives 0.0313 mol, 56% too high, the most common hydrate mistake.
How to write it: n = 5.00 g ÷ 249.677 g/mol = 0.0200 mol
500 mg vitamin C tablet to millimoles
Milligrams divided by g/mol gives millimoles.
A vitamin C tablet holds 500 mg of ascorbic acid, C6H8O6. How many millimoles is that?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| C (Carbon) | 6 | 12.011 | 72.066 | 0.02 mol |
| H (Hydrogen) | 8 | 1.008 | 8.064 | 0.02 mol |
| O (Oxygen) | 6 | 15.999 | 95.994 | 0.02 mol |
| Molar mass | 176.124 | 0.003 mol C6H8O6 |
What it means: M(C6H8O6) = 176.124 g/mol. 500 mg ÷ 176.124 g/mol = 2.84 mmol, or 0.00284 mol. Doses in milligrams and amounts in millimoles go together without converting to grams first.
How to write it: n = 500 mg ÷ 176.124 g/mol = 2.84 mmol
A teaspoon of baking soda
Kitchen chemistry in moles.
A level teaspoon holds about 5.00 g of sodium hydrogen carbonate, NaHCO3. How many moles, and how much CO2 can it release with acid?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| Na (Sodium) | 1 | 22.99 | 22.990 | 0.0595 mol |
| H (Hydrogen) | 1 | 1.008 | 1.008 | 0.0595 mol |
| C (Carbon) | 1 | 12.011 | 12.011 | 0.0595 mol |
| O (Oxygen) | 3 | 15.999 | 47.997 | 0.179 mol |
| Molar mass | 84.006 | 0.0595 mol NaHCO3 |
What it means: M(NaHCO3) = 84.006 g/mol, so 5.00 g is 0.0595 mol. With an acid, each mole of NaHCO3 gives one mole of CO2, so up to 0.0595 mol of gas, about 1.4 L at room temperature.
How to write it: n(NaHCO3) = 5.00 g ÷ 84.006 g/mol = 0.0595 mol
Weighing out 0.250 mol of NaOH
The reverse direction: multiply by M.
A recipe for a solution needs 0.250 mol of sodium hydroxide. What mass do you weigh?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| Na (Sodium) | 1 | 22.99 | 22.990 | 0.250 mol |
| O (Oxygen) | 1 | 15.999 | 15.999 | 0.250 mol |
| H (Hydrogen) | 1 | 1.008 | 1.008 | 0.250 mol |
| Molar mass | 39.997 | 0.250 mol NaOH |
What it means: m = 0.250 mol × 39.997 g/mol = 9.999 g, or 10.0 g to three significant figures. NaOH absorbs water from the air, so weigh it quickly or the real amount will be a little low.
How to write it: m(NaOH) = 0.250 mol × 39.997 g/mol = 10.0 g
One microgram of caffeine
Tiny masses still hold huge numbers of molecules.
A sensitive analysis detects 1.0 µg of caffeine, C8H10N4O2. How many molecules is that?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| C (Carbon) | 8 | 12.011 | 96.088 | 4.1 × 10−8 mol |
| H (Hydrogen) | 10 | 1.008 | 10.080 | 5.1 × 10−8 mol |
| N (Nitrogen) | 4 | 14.007 | 56.028 | 2.1 × 10−8 mol |
| O (Oxygen) | 2 | 15.999 | 31.998 | 1.0 × 10−8 mol |
| Molar mass | 194.194 | 5.1 × 10−9 mol C8H10N4O2 |
What it means: 1.0 µg ÷ 194.194 g/mol = 5.1 × 10−9 mol, which is still 3.1 × 1015 molecules. Even a millionth of a gram holds thousands of trillions of molecules, which is why chemists count in moles.
How to write it: N = (1.0 × 10−6 g ÷ 194.194 g/mol) × 6.022 × 1023 = 3.1 × 1015 molecules
CO or Co? One capital letter
Carbon monoxide and cobalt differ by a factor of two.
28.0 g of "CO". Carbon monoxide (CO) or cobalt (Co)?
| Element | Atoms per unit | Atomic weight | Subtotal (g/mol) | Moles in sample |
|---|---|---|---|---|
| C (Carbon) | 1 | 12.011 | 12.011 | 1.00 mol |
| O (Oxygen) | 1 | 15.999 | 15.999 | 1.00 mol |
| Molar mass | 28.010 | 1.00 mol CO |
What it means: As carbon monoxide, M = 28.010 g/mol and 28.0 g is 1.00 mol. As cobalt, M = 58.933 g/mol and the same 28.0 g is only 0.475 mol. The calculator reads exactly what you type, so check the formula preview.
How to write it: n(CO) = 28.0 g ÷ 28.010 g/mol = 1.00 mol (not 0.475 mol of Co)
✏️ 14. How to Calculate Moles from Grams by Hand, Step by Step
This is the written method examiners expect, on the same example as Sections 7, 9, 10 and 11: how many moles are there in 25.0 g of water?
14.1 The written method
- Write the formula and count the atoms. H2O: 2 hydrogen, 1 oxygen.
- Write the molar mass sum. M = 2 × 1.008 + 1 × 15.999 = 18.015 g/mol (or 2 × 1 + 16 = 18 g/mol with exam values).
- Make sure the mass is in grams. 25.0 g. (325 mg would be 0.325 g.)
- Write the formula. n = m ÷ M.
- Substitute with units. n = 25.0 g ÷ 18.015 g/mol. The grams cancel, leaving mol.
- Calculate. n = 1.387 732… mol.
- Round once, at the end. 25.0 has 3 significant figures, so n = 1.39 mol.
- Check. 1.39 × 18.015 = 25.0 g. The answer is sensible: water is light, so 25 g is more than one mole.
For moles to grams, swap step 4 for m = n × M. For grams to molecules, add N = n × 6.022 × 1023.
14.2 On a scientific calculator
On a Casio fx-991EX or fx-82MS: type 2 × 1.008 + 15.999 = to get 18.015. Then 25 ÷ Ans = gives 1.387732…. For molecules, × 6.022 ×10x 23 = gives 8.357 × 1023.
Use the ×10x (or EXP) key, never × 10 ^ 23 typed by hand: dividing by 6.022 × 10 ^ 23 without brackets divides by 6.022 and multiplies by 1023. Key names differ between models; check your manual.
14.3 Do it in the lab: water of crystallisation in copper(II) sulfate
Finding x in CuSO4·xH2O by heating
- Weigh a clean, dry crucible. Add about 2.5 g of blue hydrated copper(II) sulfate and weigh again.
- Heat gently on a pipeclay triangle, then more strongly, stirring, until all the solid turns white (anhydrous CuSO4).
- Let it cool in a desiccator, then weigh. Heat again for 2 minutes, cool and reweigh until two masses agree within 0.01 g (heating to constant mass).
- Mass of water lost = mass before − mass after. Convert both masses to moles with n = m ÷ M.
- x = moles of water ÷ moles of anhydrous CuSO4; round to the nearest whole number.
Hazards: copper(II) sulfate is harmful if swallowed, irritates eyes and skin, and is very toxic to aquatic life. The crucible gets very hot: handle it with tongs and let it cool on a heatproof mat. Wear eye protection, heat gently at first to stop the solid spitting, do not pour waste down the sink, and follow your school’s risk assessment.
Main errors: not heating to constant mass (x comes out too small), overheating until the white solid turns black (CuSO4 decomposes, x comes out too big), and weighing while hot.
| Measurement | Mass (g) | Moles |
|---|---|---|
| Empty crucible | 20.00 | |
| Crucible + blue hydrate | 22.50 | |
| Crucible + white anhydrous solid (constant mass) | 21.60 | |
| Hydrate used | 2.50 | |
| Anhydrous CuSO4 | 1.60 | 0.0100 mol (÷ 159.602) |
| Water lost | 0.90 | 0.050 mol (÷ 18.015) |
Example data. x = 0.0500 ÷ 0.0100 = 4.98, so x = 5: the formula is CuSO4·5H2O. The water mass (0.90 g) has only two significant figures, which limits x to about ±0.1.
14.4 Grams to moles practice problems with answers
Ten practice problems, easy to hard. Open each one to see the answer.
1. How many moles are in 9.00 g of H2O?
M = 18.015 g/mol; n = 9.00 ÷ 18.015 = 0.500 mol
2. How many moles are in 117 g of NaCl?
M = 58.440 g/mol; n = 117 ÷ 58.440 = 2.00 mol
3. What is the mass of 0.500 mol of O2?
M = 31.998 g/mol; m = 0.500 × 31.998 = 16.0 g
4. How many moles are in 66.0 g of CO2?
M = 44.009 g/mol; n = 66.0 ÷ 44.009 = 1.50 mol
5. What is the mass of 0.150 mol of CaCO3?
M = 100.086 g/mol; m = 0.150 × 100.086 = 15.0 g
6. How many moles are in 3.70 g of Ca(OH)2?
M = 74.092 g/mol; n = 3.70 ÷ 74.092 = 0.0499 mol
7. How many molecules and atoms are in 3.40 g of NH3?
n = 3.40 ÷ 17.031 = 0.200 mol; 1.20 × 1023 molecules, × 4 = 4.81 × 1023 atoms
8. How many moles are in 12.5 g of CuSO4·5H2O?
M = 249.677 g/mol; n = 12.5 ÷ 249.677 = 0.0501 mol
9. How many millimoles are in 81.0 mg of C9H8O4?
M = 180.159 g/mol; n = 81.0 ÷ 180.159 = 0.450 mmol
10. 1.28 g of a gas is 0.0200 mol. Find its molar mass and suggest what it is.
M = 1.28 ÷ 0.0200 = 64.0 g/mol, close to SO2 (64.058 g/mol).
Want more practice on paper? Print the worksheet and check your answers.
14.5 Mistakes that lose marks
Studies of how students handle the mole find the same slips again and again: treating the mole as a mass, losing track of which particle is being counted, and mixing up molar mass with mass (Gabel & Sherwood, 1984; Krishnan & Howe, 1994; Pekdağ & Azizoğlu, 2013).
- Multiplying by the molar mass when you should divide (grams to moles is m ÷ M).
- Missing atoms inside brackets: Ca(OH)2 is 74.092 g/mol, not 57.085.
- Leaving out the water in a hydrate: CuSO4·5H2O is 249.677 g/mol, not 159.602.
- Using 16 g/mol for oxygen gas instead of 32 g/mol for O2.
- Forgetting to convert mg to g, giving an answer 1000 times too big.
- Rounding the molar mass to 2 figures before dividing.
- Writing “mols” or leaving out the unit altogether.
✅ 15. When Should You Use a Grams to Moles Calculator?
- You weighed a pure substance and need the amount for a reaction.
- A question gives a mass and asks for moles, molecules or atoms.
- You are starting any stoichiometry, limiting reagent or yield problem.
- You need to compare substances by number of particles, not by mass.
- You have a solution: use n = c × V (molarity times volume in litres).
- You have a gas volume: use n = V ÷ Vm or PV = nRT.
- The sample is a mixture: find the mass of the pure substance first (mass × purity).
- You only know percent composition: use an empirical formula method.
Four real examples
| Situation | Method | Result |
|---|---|---|
| 5.85 g of NaCl weighed into a flask | n = m ÷ M | 0.100 mol |
| 25.0 mL of 0.100 M HCl from a burette | n = c × V | 2.50 × 10−3 mol |
| 240 cm3 of CO2 gas at room temperature (GCSE) | n = V ÷ 24.0 dm3/mol | 0.0100 mol |
| A 500 mg tablet that is 80% active ingredient | Pure mass first: 400 mg, then n = m ÷ M | Depends on M |
Decision tree
- Do you have a mass of a pure substance? Yes: grams to moles (this calculator). No: go on.
- Do you have a concentration and a volume? Yes: n = c × V. No: go on.
- Do you have a gas volume, temperature and pressure? Yes: PV = nRT, or V ÷ Vm at a stated STP.
- Do you have a number of particles? Yes: n = N ÷ NA (the particles mode here).
🔧 16. Grams to Moles Calculator Troubleshooting and Common Mistakes
My answer is 1000 times too big or too small
Cause: mg and g mixed up, or mmol and mol. Fix: pick the right unit next to the number; the calculator converts. Remember mg ÷ g/mol gives mmol.
"Element symbols start with a capital letter"
Cause: a lowercase symbol such as h2o or nacl. Fix: type H2O and NaCl. Phones capitalise the first letter of a word; the box switches that off, but check pasted text.
My molar mass is slightly different from the textbook
Cause: a different set of atomic weights. Fix: switch to rounded exam values in Section 2. The difference is usually in the second or third decimal place.
The answer has fewer decimals than I expected
Cause: the significant figures come from your mass. 25 has 2, 25.0 has 3. Fix: type the mass exactly as measured, or choose a fixed number of significant figures.
I got the molar mass of the wrong substance
Cause: Co (cobalt, 58.933 g/mol) typed for CO (carbon monoxide, 28.010 g/mol), or O typed for O2. Fix: check the formula preview under the box before pressing Convert.
"Mass cannot be negative" or "zero has zero moles"
Cause: a minus sign or a zero in the mass box. Fix: enter the positive mass you weighed. A mass difference (for example water lost on heating) should be entered as a positive number.
My sample is impure or a mixture
Cause: the mass includes other substances. Fix: type the purity in the Purity box (for example 98 for 98%). The calculator converts only the pure part, and in moles to grams mode it tells you how much impure sample to weigh.
My hydrate answer is wrong
Cause: the water of crystallisation was left out. Fix: type the hydrate with a dot: CuSO4.5H2O. The molar mass becomes 249.677 g/mol instead of 159.602.
I only know the molar mass, not the formula
Cause: the question gives M directly, or the substance has no simple formula. Fix: leave the formula box empty and type the molar mass in g/mol. Element tables and atom counts are skipped, since they need a formula.
"The number of particles must be greater than 0" or my power of ten is ignored
Cause: the number was typed as 6.02*10^23 with a symbol the box cannot read. Fix: type 6.02e23 or 6.02 x 10^23.
⚖️ 17. Assumptions and Limitations of the Grams to Moles Calculator
| Assumption | What it requires | How to check | If it fails |
|---|---|---|---|
| The sample is pure (or its purity is entered) | All the mass is the substance in the formula, or you typed the purity | Purity on the label or certificate | Moles are overestimated: impurities add mass but not moles of your substance |
| The formula is right | Correct formula, hydrate water included | Compare with a data book | A hydrate typed as anhydrous gives a molar mass that is too small, so moles are overestimated |
| The sample is dry | No absorbed water (NaOH, CaCl2 absorb it) | Heat to constant mass, or use a desiccator | Moles are overestimated |
| Natural isotope mix | Standard atomic weights apply | Normal lab chemicals | Isotopically enriched samples (D2O, 13C) need their own molar mass |
| Ideal gas (gas volume line only) | Low pressure, high temperature, a real gas | Is the substance a gas at those conditions? | The volume is meaningless for liquids and solids, and a few percent off for real gases near condensation |
Limitations. A grams to moles calculator turns mass into amount, but it cannot tell you whether the mass belongs to the substance you think it does. Molar masses of ions ignore the electron mass (under 0.003% for most ions). For elements with no standard atomic weight, such as Tc, the mass number of the longest-lived isotope is used and a note appears.
🎯 18. Conclusion
What the answer is
A grams to moles calculator divides a mass by a molar mass. For the headline problem, 25.0 g of water ÷ 18.015 g/mol = 1.39 mol, which is 8.36 × 1023 molecules and 2.51 × 1024 atoms.
What it means chemically
Moles count particles. Chemical equations, concentrations and gas laws all work in moles, not grams, so converting grams to moles is how a mass on a balance becomes something chemistry can use.
Watch out for
Get the molar mass right first: brackets, hydrates and capital letters cause most wrong answers. Convert mg to g, divide rather than multiply, and round only once, to the significant figures of the mass.
Next steps
Use your moles with the mole ratio from a balanced equation to find a product mass or the limiting reagent, or practise with the 25 worked conversions in Section 12 and the ten problems in Section 14. For every reacting-mass problem, the first step is the same: the grams to moles calculator.
❓ 19. Frequently Asked Questions
What is a grams to moles calculator?
A grams to moles calculator converts the mass of a substance into the amount in moles by dividing by its molar mass, n = m / M. This one also works out the molar mass from the formula and shows every step, the number of molecules and atoms, and a mole map.
How do you calculate moles from grams?
Divide the mass in grams by the molar mass in g/mol: n = m / M. For 25.0 g of water, M = 18.015 g/mol, so n = 25.0 / 18.015 = 1.39 mol.
How do you calculate grams from moles?
Multiply the moles by the molar mass: m = n x M. For 2.50 mol of carbon dioxide, m = 2.50 x 44.009 = 110 g, written 1.10 x 10^2 g to show three significant figures.
What is the formula for converting grams to moles?
The formula is moles = mass / molar mass, written n = m / M, with m in grams, M in grams per mole and n in moles. Rearranged, mass = moles x molar mass and molar mass = mass / moles.
How do you calculate molar mass from a chemical formula?
Multiply the atomic weight of each element by the number of its atoms in the formula and add them up. Water: 2 x 1.008 + 1 x 15.999 = 18.015 g/mol. Multiply through brackets, and add the water in a hydrate.
How many moles are in 25 grams of water?
25.0 g of water is 1.39 mol, because the molar mass of H2O is 18.015 g/mol and 25.0 / 18.015 = 1.3877 mol. That is 8.36 x 10^23 water molecules.
How do you convert grams to atoms or molecules?
Convert grams to moles with n = m / M, then multiply by Avogadro's constant, 6.02214076 x 10^23 per mole. For atoms in a compound, multiply the number of molecules by the atoms in one molecule. 1.00 g of gold is 3.06 x 10^21 atoms.
How many moles are in 100 grams of water?
100 grams of water is 5.55 mol, because 100 / 18.015 g/mol = 5.551 mol. That is 3.34 x 10^24 water molecules. Likewise 10.0 g of NaCl is 0.171 mol (10.0 / 58.44).
What is Avogadro's number and how is it used with moles?
Avogadro's number is the number of particles in one mole, exactly 6.02214076 x 10^23 since the 2019 SI redefinition. Multiply moles by it to get particles, and divide particles by it to get moles.
How do you convert milligrams to moles?
Divide the milligrams by 1000 to get grams, then divide by the molar mass. A shortcut: milligrams divided by g/mol gives millimoles. A 325 mg aspirin tablet (M = 180.159 g/mol) is 1.80 mmol, or 0.00180 mol.
How many significant figures should a moles answer have?
The same as the measured mass, because the molar mass is known more precisely and Avogadro's constant is exact. 25.0 g has three significant figures, so the answer is 1.39 mol. Keep all digits until the final step.
Is molar mass the same as molecular weight?
They are the same number with different units: the molecular weight (relative molecular mass, Mr) of water is 18.015 with no unit, and its molar mass is 18.015 g/mol. Neither is the same as mass: 25.0 g and 100 g of water both have a molar mass of 18.015 g/mol.
How do you find molar mass from grams and moles?
Divide the mass by the moles: M = m / n. If 4.40 g of a gas is 0.100 mol, M = 44.0 g/mol, which matches carbon dioxide (44.009) or dinitrogen oxide (44.013).
How do you use grams to moles in stoichiometry?
Convert the given mass to moles, multiply by the mole ratio from the balanced equation, then convert the moles of the product back to grams with its molar mass. This grams to moles to grams route solves most reacting-mass problems.
How do you convert grams to moles in Excel?
Put the element counts and atomic weights in two columns, get the molar mass with =SUMPRODUCT(B2:B3,C2:C3), then divide the mass by it with =F2/D4. Section 9 shows the sheet step by step for 25.0 g of water.
How do you calculate grams to moles in Python?
Compute the molar mass from a dictionary of atomic weights and the atom counts, then n = mass_g / M. The periodictable package does it in one line: 25.0 / periodictable.formula("H2O").mass. Section 11 has a complete script.
How do you calculate grams to moles in R?
Store the atomic weights in a named vector, add up counts times weights to get M, then divide: n <- mass_g / M, and round with signif(n, 3). Section 10 has a complete base R script that also saves a figure.
How do you calculate moles on a scientific calculator?
Work out the molar mass first (2 x 1.008 + 15.999 = 18.015), then divide the mass by Ans: 25 / Ans = 1.3877. Use the x10^x or EXP key for Avogadro's constant, never x 10 ^ 23 typed by hand.
Should I use 12 or 12.011 for carbon, and 16 or 15.999 for oxygen?
Use whatever your exam or textbook gives. CBSE, GCSE and IGCSE papers usually give rounded values (C 12, O 16, Cl 35.5); university work uses the CIAAW standard values (C 12.011, O 15.999). The answer usually changes only in the last digit.
How do you calculate mole fraction given grams?
Convert the grams of each component to moles with n = m / M, add them to get the total moles, then divide each component's moles by the total. For 18.0 g water and 46.0 g ethanol: 0.999 mol each, so each mole fraction is 0.500.
📑 20. Cite This Tool
StatsUnlock Team. (2026). Grams to moles calculator [Interactive chemistry tool]. StatsUnlock. https://statsunlock.com/grams-to-moles-calculator/@misc{statsunlock_g2m_2026, title={Grams to Moles Calculator}, author={{StatsUnlock Team}}, year={2026}, note={Interactive chemistry tool}, url={https://statsunlock.com/grams-to-moles-calculator/}}Amounts of substance were calculated with the StatsUnlock Grams to Moles Calculator (2026) using n = m / M, with molar masses from CIAAW 2024 standard atomic weights and N_A = 6.02214076 x 10^23 mol^-1.🔗 21. Related Tools
Quick arithmetic for molar mass sums and divisions.
Open tool →Rearrange n = m / M for any unknown, with steps.
Open tool →Test whether two measured yields or amounts really differ.
Open tool →How many repeat weighings or runs an experiment needs.
Open tool →How big a difference between two methods is, not just whether it exists.
Open tool →Check an experiment is large enough to see the change you expect.
Open tool →The chance of a false positive or a missed real effect.
Open tool →How much variation in an ANOVA your treatment explains.
Open tool →Rearranging n = m ÷ M is algebra, and judging whether two measured amounts really differ is statistics; these tools cover both.
📖 22. Glossary of Terms
| Term | Plain-English meaning |
|---|---|
| Amount of substance (n) | How many particles a sample holds, counted in moles (mol). |
| Anhydrous | A salt with its water of crystallisation removed, for example white CuSO4. |
| Atomic weight (Ar) | The average mass of an element’s atoms relative to 1/12 of a carbon-12 atom. No unit. |
| Avogadro constant (NA) | Exactly 6.022 140 76 × 1023 mol−1: the number of particles in one mole. |
| Formula unit | The simplest repeating group in an ionic compound, such as one Na+ and one Cl− in NaCl. |
| Gram (g) | The unit of mass used with molar mass; 1000 g = 1 kg. |
| Hydrate | A salt with water built into its crystals, written with a dot: CuSO4·5H2O. |
| Mass (m) | How heavy a sample is, in grams. |
| Millimole (mmol) | One thousandth of a mole. |
| Molar mass (M) | The mass of one mole of a substance, in g/mol. |
| Molar volume (Vm) | The volume of one mole of an ideal gas at stated conditions, for example 22.711 L/mol at 0 °C and 1 bar. |
| Molarity (c) | Moles of solute per litre of solution, mol/L or M. |
| Mole (mol) | The SI unit of amount of substance: exactly 6.022 140 76 × 1023 particles. |
| Mole fraction | Moles of one component divided by the total moles in a mixture. No unit. |
| Molecule | A group of atoms joined by covalent bonds, such as H2O. |
| Relative molecular mass (Mr) | The sum of the atomic weights in a formula; the same number as the molar mass, without the unit. |
| Significant figures | The digits in a measurement that carry meaning; they set how far to round the answer. |
| STP | Standard temperature and pressure: IUPAC uses 0 °C and 1 bar; older books use 0 °C and 1 atm. |
| Stoichiometry | Calculating amounts of reactants and products from a balanced equation. |
| Water of crystallisation | Water molecules held in a crystal, released on heating. |
📚 23. References
Peer-reviewed sources for the methods and data used in this grams to moles calculator: the definition of the mole, the Avogadro constant, standard atomic weights, and research on how students learn the mole concept and stoichiometry.
- Andreas, B., Azuma, Y., Bartl, G., Becker, P., Bettin, H., Borys, M., ... Zakel, S. (2011). Determination of the Avogadro constant by counting the atoms in a 28Si crystal. Physical Review Letters, 106(3), 030801. https://doi.org/10.1103/PhysRevLett.106.030801
- Azuma, Y., Barat, P., Bartl, G., Bettin, H., Borys, M., Busch, I., ... Zakel, S. (2015). Improved measurement results for the Avogadro constant using a 28Si-enriched crystal. Metrologia, 52(2), 360–375. https://doi.org/10.1088/0026-1394/52/2/360
- Dori, Y. J., & Hameiri, M. (2003). Multidimensional analysis system for quantitative chemistry problems: Symbol, macro, micro, and process aspects. Journal of Research in Science Teaching, 40(3), 278–302. https://doi.org/10.1002/tea.10077
- Furió, C., Azcona, R., & Guisasola, J. (2002). The learning and teaching of the concepts ‘amount of substance’ and ‘mole’: A review of the literature. Chemistry Education Research and Practice, 3(3), 277–292. https://doi.org/10.1039/B2RP90023H
- Gabel, D. L., & Sherwood, R. D. (1984). Analyzing difficulties with mole-concept tasks by using familiar analog tasks. Journal of Research in Science Teaching, 21(8), 843–851. https://doi.org/10.1002/tea.3660210806
- Güttler, B., Bettin, H., Brown, R. J. C., Davis, R. S., Mester, Z., Milton, M. J. T., ... Stock, M. (2019). Amount of substance – the Avogadro constant and the SI unit “mole”. Metrologia, 56(4), 044002. https://doi.org/10.1088/1681-7575/ab1fae
- Krishnan, S. R., & Howe, A. C. (1994). The mole concept: Developing an instrument to assess conceptual understanding. Journal of Chemical Education, 71(8), 653–655. https://doi.org/10.1021/ed071p653
- Marquardt, R., Meija, J., Mester, Z., Towns, M., Weir, R., Davis, R., & Stohner, J. (2018). Definition of the mole (IUPAC Recommendation 2017). Pure and Applied Chemistry, 90(1), 175–180. https://doi.org/10.1515/pac-2017-0106
- Meija, J., Coplen, T. B., Berglund, M., Brand, W. A., De Bièvre, P., Gröning, M., ... Prohaska, T. (2016). Atomic weights of the elements 2013 (IUPAC Technical Report). Pure and Applied Chemistry, 88(3), 265–291. https://doi.org/10.1515/pac-2015-0305
- Mills, I. M., Mohr, P. J., Quinn, T. J., Taylor, B. N., & Williams, E. R. (2006). Redefinition of the kilogram, ampere, kelvin and mole: A proposed approach to implementing CIPM recommendation 1 (CI-2005). Metrologia, 43(3), 227–246. https://doi.org/10.1088/0026-1394/43/3/006
- Nakhleh, M. B. (1992). Why some students don’t learn chemistry: Chemical misconceptions. Journal of Chemical Education, 69(3), 191–196. https://doi.org/10.1021/ed069p191
- Newell, D. B., Cabiati, F., Fischer, J., Fujii, K., Karshenboim, S. G., Margolis, H. S., ... Ullrich, J. N. (2018). The CODATA 2017 values of h, e, k, and NA for the revision of the SI. Metrologia, 55(1), L13–L16. https://doi.org/10.1088/1681-7575/aa950a
- Nurrenbern, S. C., & Pickering, M. (1987). Concept learning versus problem solving: Is there a difference? Journal of Chemical Education, 64(6), 508–510. https://doi.org/10.1021/ed064p508
- Pekdağ, B., & Azizoğlu, N. (2013). Semantic mistakes and didactic difficulties in teaching the “amount of substance” concept: A useful model. Chemistry Education Research and Practice, 14(1), 117–129. https://doi.org/10.1039/C2RP20132A
- Prohaska, T., Irrgeher, J., Benefield, J., Böhlke, J. K., Chesson, L. A., Coplen, T. B., ... Zhu, X. (2022). Standard atomic weights of the elements 2021 (IUPAC Technical Report). Pure and Applied Chemistry, 94(5), 573–600. https://doi.org/10.1515/pac-2019-0603
- Sanger, M. J. (2005). Evaluating students’ conceptual understanding of balanced equations and stoichiometric ratios using a particulate drawing. Journal of Chemical Education, 82(1), 131–134. https://doi.org/10.1021/ed082p131
- Schmidt, H.-J., & Jignéus, C. (2003). Students’ strategies in solving algorithmic stoichiometry problems. Chemistry Education Research and Practice, 4(3), 305–317. https://doi.org/10.1039/B3RP90018E
- Staver, J. R., & Lumpe, A. T. (1995). Two investigations of students’ understanding of the mole concept and its use in problem solving. Journal of Research in Science Teaching, 32(2), 177–193. https://doi.org/10.1002/tea.3660320206
- Tiesinga, E., Mohr, P. J., Newell, D. B., & Taylor, B. N. (2021). CODATA recommended values of the fundamental physical constants: 2018. Reviews of Modern Physics, 93(2), 025010. https://doi.org/10.1103/RevModPhys.93.025010
- Yarroch, W. L. (1985). Student understanding of chemical equation balancing. Journal of Research in Science Teaching, 22(5), 449–459. https://doi.org/10.1002/tea.3660220507
