How the molecular weight calculator works
Enter a chemical formula to find its molar mass, the mass of one mole in grams per mole (g/mol). The calculator counts each element's atoms, multiplies those counts by the corresponding atomic weights and adds the contributions. Brackets and hydrate water are included in the atom counts.
The composition table shows each element's atom count, atomic weight, contribution to the molar mass and mass percentage. The worked arithmetic explains the total. An optional mass in grams or amount in moles lets you convert between the two and find the corresponding number of entities: molecules, formula units or atoms, depending on the substance.
The molar mass and mass percentage formulas
Add one contribution for each element. Expand brackets and hydrate multipliers before doing the multiplication.
Element share is that element's contribution to the total molar mass. Mass percentage is not the percentage of atoms.
Worked example: glucose
For glucose, enter C6H12O6. Each molecule contains 6 carbon atoms, 12 hydrogen atoms and 6 oxygen atoms, or 24 atoms altogether. Using carbon at 12.011, hydrogen at 1.0080 and oxygen at 15.999 gives the following calculation.
| Element | Atoms | Atomic weight | Share (g/mol) | Mass percent |
|---|---|---|---|---|
| Carbon | 6 | 12.011 | 72.066 | 40.00% |
| Hydrogen | 12 | 1.0080 | 12.096 | 6.71% |
| Oxygen | 6 | 15.999 | 95.994 | 53.28% |
Carbon's mass percentage is 100 × 72.066 ÷ 180.156 = 40.00%. Although hydrogen accounts for half the atoms, it contributes only 6.71% of the mass. Rounded percentages may not add to exactly 100%.
| Substance | Formula | Molar mass |
|---|---|---|
| Water | H2O | 18.015 g/mol |
| Carbon dioxide | CO2 | 44.009 g/mol |
| Ethanol | C2H5OH | 46.069 g/mol |
| Sodium chloride | NaCl | 58.440 g/mol |
| Calcium carbonate | CaCO3 | 100.086 g/mol |
| Ammonium sulfate | (NH4)2SO4 | 132.134 g/mol |
| Glucose | C6H12O6 | 180.156 g/mol |
| Copper(II) sulfate pentahydrate | CuSO4·5H2O | 249.677 g/mol |
Counting brackets and hydrates
A number after a closing bracket multiplies every atom inside that group. In (NH4)2SO4, the 2 gives 2 nitrogen atoms and 8 hydrogen atoms; sulfur remains 1 and oxygen remains 4. The molar mass is 2 × 14.007 + 8 × 1.0080 + 32.06 + 4 × 15.999 = 132.134 g/mol.
For CuSO4·5H2O, the 5 multiplies the entire water formula. The total counts are 1 copper, 1 sulfur, 9 oxygen and 10 hydrogen atoms. Copper(II) sulfate contributes 159.602 g/mol, and the water contributes 5 × 18.015 = 90.075 g/mol, giving 249.677 g/mol. Leaving out the hydrate water changes both the molar mass and the elemental mass percentages.
Converting grams, moles and entity counts
Use the molar mass calculated from the complete formula, including any hydrate water.
Count molecules for molecular substances, formula units for ionic compounds, or atoms for monatomic elements.
For 100 g of glucose, divide 100 by 180.156 to get 0.5551 mol. Multiplying the unrounded amount by the Avogadro constant gives about 3.343 × 1023 molecules. In the other direction, 2 mol of water has a mass of 2 × 18.015 = 36.03 g. Changing the sample amount does not change its molar mass.
Molecular weight, molar mass and precision
Molecular weight, strictly called relative molecular mass, is a ratio and has no unit. Molecular mass is expressed in daltons (Da), also called unified atomic mass units (u). Molar mass is expressed here in g/mol. At the precision used on this page, glucose's relative molecular mass of 180.156, average molecular mass of 180.156 Da and molar mass of 180.156 g/mol have matching numerical values.
For an ionic compound such as NaCl, use the term formula mass instead of molecular mass because the solid does not consist of separate NaCl molecules. The atom-counting arithmetic is unchanged.
The calculations use CIAAW's 2024 abridged standard atomic weights. These describe normal terrestrial materials; natural isotope proportions and measurement uncertainty limit their precision. Displaying three decimal places does not mean every result is accurate to 0.001 g/mol, and this method does not give isotope-specific or monoisotopic masses.
Entering a formula correctly
- 1Check symbols and capitalization. Enter a formula, not a substance name. Co means cobalt, while CO contains carbon and oxygen. Ordinary digits such as H2O work; pasted subscripts such as H₂O are also accepted.
- 2Keep groups and hydrate water together. Use matching parentheses, square brackets or braces, including nested groups such as K4[Fe(CN)6]. Separate hydrate parts with a middle dot or full stop: CuSO4·5H2O or CuSO4.5H2O.
- 3Separate charge and sample amount. Write an ionic charge after ^, as in SO4^2- or NH4^+. Charge does not change the atom counts, and electron-mass corrections are omitted. Enter the amount separately instead of putting a reaction coefficient before the formula.
Frequently asked questions
What is the molecular weight of water?
Using these atomic weights, water's relative molecular mass is 18.015, without a unit. Its molar mass is 18.015 g/mol: 2 × 1.0080 + 15.999.
Is molecular weight the same as molar mass?
They are different quantities with matching numerical values at the precision used here. Molecular weight is dimensionless, while molar mass is mass per mole. A result labeled g/mol is a molar mass.
How many moles are in 100 grams of glucose?
There are about 0.5551 mol, using 100 ÷ 180.156. This assumes the full 100 g is glucose with the formula C6H12O6, not a solution or mixture.
What is the molar mass of NaCl?
It is 58.440 g/mol using sodium at 22.990 and chlorine at 35.45. For solid sodium chloride, an entity count refers to formula units, not molecules.
Does 2H2O have twice the molar mass of water?
No. A reaction coefficient of 2 specifies twice the number of water entities or twice the amount in moles. Enter H2O and 2 mol to find a mass of 36.03 g; water's molar mass remains 18.015 g/mol.
Why do molecular weight calculators give different answers?
They may use different atomic-weight editions, different rounding or isotope-specific masses. This page uses the numerical values in CIAAW's 2024 abridged table. Compare the atomic weights and the complete formula, including hydrate water, before comparing final results.
Sources
- 1Abridged Standard Atomic Weights 2024 · Commission on Isotopic Abundances and Atomic Weights · Accessed November 2026
- 2Chemistry 2e, section 3.1: Formula Mass and the Mole Concept · OpenStax, Rice University · Accessed November 2026
- 3Chemistry 2e, section 3.2: Determining Empirical and Molecular Formulas · OpenStax, Rice University · Accessed November 2026
- 4Mise en pratique for the definition of the mole in the SI · International Bureau of Weights and Measures · Accessed November 2026
- 5Definitions of terms relating to individual macromolecules, macromolecular assemblies, polymer solutions, and amorphous bulk polymers (IUPAC Recommendations 2014) · De Gruyter and the International Union of Pure and Applied Chemistry · Accessed November 2026