Moles and Chemical Formula Calculator

Formulas may use brackets and hydrates: Ca(OH)2, Al2(SO4)3 and CuSO4·5H2O all parse. Element symbols are case-sensitive, as chemistry requires: Co is cobalt, CO is carbon monoxide.

Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice. Atomic weights are the standard conventional values; real samples vary slightly with isotopic composition, and laboratory work should use measured data.

What this calculator does

Almost all of quantitative chemistry runs through one hub: the mole. This page parses a chemical formula (brackets and hydrates included), computes its molar mass from standard atomic weights, breaks the mass down element by element into a percent composition, and converts between grams, moles and particle counts through Avogadro’s constant. In the other direction, it takes a measured composition, by percent or by grams, and works it back to an empirical formula with the mole-ratio steps shown, then to a molecular formula when a measured molar mass is supplied. Every conversion the variants of this tool are searched for (moles to mass, atoms to grams, molecules to moles, percent composition, empirical formula) is the same hub seen from a different side, and each result here shows which side it came from.

How to use it

  • Type the formula as chemists write it. Capital letter first for each element, subscripts as plain numbers, brackets for groups: Ca(OH)2, Al2(SO4)3, K4[Fe(CN)6]. Hydrates take a middle dot or a full stop: CuSO4·5H2O. Case is not decoration: Co (cobalt) and CO (carbon plus oxygen) are different substances.
  • Add an amount to convert. Choose mass, moles or particle count and enter the value; scientific notation such as 3.011e23 is accepted for particle counts. Leave it blank for analysis alone.
  • For an unknown, use composition mode. Enter each element with its percent by mass (or the grams found in a sample). Percentages should add to about 100; the page checks and says so if they stray. Add a measured molar mass to turn the empirical formula into the molecular one.
  • Mind significant figures. Results are shown to a sensible precision for the standard atomic weights; a school answer may round harder, and the method text explains the convention.

The method

Molar mass is a sum: for each element, its count in the formula multiplied by its standard atomic weight (the CIAAW conventional values, the same numbers printed on periodic tables, such as C 12.011 and O 15.999), added across the formula. Percent composition is each element’s share of that sum. Amount conversions run through n = m / M (moles = mass ÷ molar mass) and N = n × Nₐ, where Nₐ is Avogadro’s constant, exactly 6.02214076 × 10^23 per mole since the 2019 SI redefinition, so a mole of anything is that many of its formula units and weighs its molar mass in grams. Empirical formulas reverse the flow: divide each element’s mass (per 100 g for percents) by its atomic weight to get relative moles, divide through by the smallest, then multiply by the smallest whole number, 1 to 8, that brings every ratio within tolerance of a whole number; that tolerance search is what turns a ratio like 1 : 1.5 into the honest 2 : 3 instead of a rounded fiction. A molecular formula is the empirical formula scaled by the measured molar mass divided by the empirical mass, rounded to the nearest whole number.

Worked examples

Glucose, the loaded defaults in composition mode. Percent composition 40.0% C, 6.7% H, 53.3% O: moles per 100 g are 40.0/12.011 = 3.330, 6.7/1.008 = 6.647 and 53.3/15.999 = 3.331; dividing by 3.330 gives 1 : 1.996 : 1.000, whole numbers at once: CH2O, empirical mass 30.026 g/mol. Against a measured molar mass of 180.156 the scale factor is 6, giving the molecular formula C6H12O6, whose own analysis reads back a molar mass of 180.156 g/mol and 40.00% carbon: the two directions agree, as they must.

Water, converted three ways. H2O has molar mass 18.015 g/mol (2 × 1.008 + 15.999). A 36.03 g sample is 36.03/18.015 = 2.000 mol, and 2.000 × 6.02214076 × 10^23 = 1.2044 × 10^24 molecules. Run backwards, half a mole of anything weighs half its molar mass: 0.5 mol of CO2 (44.009 g/mol) is 22.00 g and 3.011 × 10^23 molecules.

A bracketed formula. Aluminium sulfate, Al2(SO4)3: the bracket triples everything inside it, so the counts are Al 2, S 3, O 12, and the molar mass is 2(26.982) + 3(32.06) + 12(15.999) = 342.13 g/mol. The parser handles the nesting so the arithmetic a student does by hand is the arithmetic shown.

The ratio that is not whole. A compound at 69.94% iron and 30.06% oxygen: moles 1.252 and 1.879, ratio 1 : 1.500, which no rounding may lawfully call 1:2 or 1:1; multiplying by 2 gives 2 : 3.000, so the empirical formula is Fe2O3. The tolerance search exists for exactly this case.

Reading your result

The breakdown table is the audit trail for the molar mass: counts, atomic weights and contributions, so any textbook disagreement can be traced to a specific weight (some tables print S as 32.07 or Cl as 35.453; totals move in the last decimal). Percent composition always sums to 100 within rounding. In composition mode, read the steps, not just the formula: the multiplier found and the worst deviation from a whole number are reported, and a large deviation is the tool telling you the data, or an assumed element, may be off. Particle counts are given in scientific notation because a mole-scale count has 24 digits; that is the honest way to write it, not a dodge.

Limitations

  • Standard atomic weights are averages. Elements are mixtures of isotopes and the natural mix varies slightly by source (sulfur and lithium are the famous wanderers). The conventional weights used here are the periodic-table standard; mass spectrometry and isotope work use isotope-specific masses, a different table for a different job.
  • The parser takes formulas, not names or structures. “Glucose” must be entered as C6H12O6, and a structural formula with bonds will not parse. Charge notation for ions (SO4 with a 2− charge) is not accepted; enter the neutral formula of the salt or the ion’s atom counts without the charge.
  • Empirical results inherit measurement error. Real analyses rarely land within tolerance of whole ratios; the tool reports the best whole-number fit and its deviation rather than silently forcing one, and an implausible formula is usually the data asking to be re-measured.

Frequently asked questions

What is a mole, really?

A counting unit, like a dozen, scaled to the laboratory: exactly 6.02214076 × 10^23 items. Its size is chosen so that one mole of a substance weighs, in grams, the same number as its molar mass, which is why the mole is the bridge between the atomic scale (where masses are tiny) and the bench scale (where things are weighed). Every conversion on this page is that bridge crossed in one direction or the other.

Why does my textbook’s molar mass differ in the last digit?

Because atomic weights are published to different precisions and occasionally revised. This page uses the CIAAW conventional values (H 1.008, C 12.011, O 15.999, S 32.06, Cl 35.45 and so on). A school table rounded to whole numbers gives glucose as 180 rather than 180.156; both are the same sum at different rounding, and for percent composition or mole work the difference almost never matters. Where it might, the breakdown table shows exactly which weights were used.

What is the difference between empirical and molecular formulas?

The empirical formula is the smallest whole-number ratio of atoms (CH2O for glucose); the molecular formula is the actual count in one molecule (C6H12O6). Composition alone can only ever give the ratio, which is why the molecular step needs an independent measurement of molar mass. Several real substances share an empirical formula: formaldehyde, acetic acid and glucose are all CH2O at heart, at masses 30, 60 and 180.

How do I convert atoms to grams?

Divide by Avogadro’s constant to get moles, then multiply by the molar mass: grams = atoms ÷ 6.02214076 × 10^23 × M. The formula mode does it in one step if you enter the particle count as the amount. The reverse (grams to atoms) divides by the molar mass first, then multiplies by the constant. Both directions appear in the results table whenever an amount is entered.

Related calculators

Method: recursive formula parsing (nested brackets and hydrate dots), molar mass as the count-weighted sum of CIAAW conventional atomic weights, percent composition from the same sum, conversions through n = m/M and N = n × 6.02214076 × 10^23 (Avogadro’s constant, exact by SI definition); empirical formulas by mole-ratio normalisation with a whole-number tolerance search over multipliers 1 to 8 and the worst deviation reported. Last reviewed: 24 October 2026.