Convert mass to moles using molar mass — supports chemical formulas and single elements
The grams to moles calculator is an essential tool for students, teachers, and professionals working in chemistry, biochemistry, pharmacology, and materials science. Whether you are preparing a solution, carrying out stoichiometric calculations, or simply checking your homework, converting mass in grams to the corresponding number of moles is one of the most frequent tasks in quantitative chemistry. At the heart of the calculation lies the molar mass — the mass of one mole of a substance, measured in grams per mole (g/mol). The molar mass of any element is numerically equal to its atomic mass listed on the periodic table. For compounds, you add up the atomic masses of all the constituent atoms. Once you know the molar mass, the conversion is straightforward: divide the mass in grams by the molar mass to get moles, or multiply the number of moles by the molar mass to get grams. This calculator handles both directions automatically. Switch between Grams → Moles and Moles → Grams with a single click. You can type any chemical formula directly — for example H2O, NaCl, C6H12O6, or H2SO4 — and the built-in parser will work out the molar mass for you, displaying how each element contributes to the total. If you are working with a custom polymer, a mixture, or any substance whose formula is not in the standard element list, you can override the molar mass manually. Beyond the basic conversion, the calculator also computes the number of molecules in your sample using Avogadro's constant (6.022 × 10²³ molecules per mole). For single-element substances, it further calculates the total number of atoms. These outputs are given in scientific notation for clarity when working with very large or very small quantities. For visual learners, the elemental composition section shows a horizontal bar chart of how each element contributes to the compound's molar mass by percentage. This is particularly helpful when studying empirical and molecular formulas, or when verifying that your formula is correct before starting an experiment. Common use cases include preparing molar solutions in a laboratory (weighing out the right mass of reagent), balancing chemical equations for stoichiometry problems, dosage calculations in pharmaceutical chemistry, and industrial process chemistry where precise mass-to-mole conversions reduce waste and ensure product quality. The tool supports 32 of the most commonly encountered elements and includes eight quick-select buttons for the most popular compounds: water (H₂O), sodium chloride (NaCl), carbon dioxide (CO₂), glucose (C₆H₁₂O₆), sulfuric acid (H₂SO₄), hydrochloric acid (HCl), ammonia (NH₃), and sodium hydroxide (NaOH). Results can be exported as a CSV file for record-keeping or pasted into lab reports and spreadsheets.
Understanding Moles and Molar Mass
What Is a Mole?
A mole is the SI unit of amount of substance. One mole contains exactly 6.02214076 × 10²³ elementary entities — this number is known as Avogadro's constant (Nₐ). The mole concept was introduced to bridge the gap between the atomic scale (where masses are measured in atomic mass units, u) and the laboratory scale (where masses are measured in grams). Because atoms are unimaginably small, a single gram of hydrogen contains about 6 × 10²³ hydrogen atoms — precisely one mole. The mole allows chemists to count atoms and molecules by weighing, which is far more practical than trying to count individual particles. In equations, the amount of substance n is related to mass m and molar mass M by the formula n = m / M.
How Is the Conversion Calculated?
The molar mass M of a substance is the mass of one mole of that substance in grams per mole (g/mol). For elements, M is numerically equal to the atomic mass in atomic mass units (e.g., carbon has an atomic mass of 12.011 u, so its molar mass is 12.011 g/mol). For compounds, M is the sum of the molar masses of all atoms in the formula: for water H₂O, M = 2 × 1.008 + 1 × 15.999 = 18.015 g/mol. Once M is known, the conversion follows two equations: moles = grams ÷ molar mass (n = m / M) and grams = moles × molar mass (m = n × M). The number of molecules is then n × Nₐ, and for single-element substances the number of atoms equals molecules × atoms per molecule.
Why Does This Conversion Matter?
Virtually all quantitative chemistry depends on the mole concept. When a recipe calls for 1 mol of sodium hydroxide to make a 1 M solution in 1 litre of water, you need to weigh out exactly 40.00 g. Pharmaceutical chemists use molar conversions to calculate drug doses and reaction yields. Industrial chemists use them to ensure that reagents are present in the correct stoichiometric ratios, minimising waste and maximising yield. Students need them for every stoichiometry and limiting-reagent problem. Without the ability to convert between grams and moles accurately, it is impossible to carry out reproducible quantitative experiments.
Limitations and Notes
This calculator uses standard atomic masses from IUPAC recommendations, which are weighted averages of the natural isotope abundances on Earth. For highly precise work (e.g., isotope ratio mass spectrometry) you may need isotopically enriched or depleted molar masses. The formula parser supports simple molecular formulas without parentheses — for example C6H12O6 is supported but Ca(OH)2 is not; in such cases, use the molar mass override field. Molar masses in this tool are rounded to three to four decimal places; for NIST-grade precision, consult authoritative atomic weight tables. Finally, the calculator assumes pure substances; for mixtures or hydrates, calculate the molar mass manually and enter it in the override field.
Grams-to-Moles Conversion Formulas
Grams to Moles
n = m / M
Number of moles equals mass in grams divided by the molar mass in g/mol. This is the primary conversion formula for determining how many moles are in a weighed sample.
Number of Molecules
N = n × 6.022 × 10²³
Multiply the number of moles by Avogadro's constant to find the total number of molecules or formula units in the sample.
Molar Concentration
C (mol/L) = n / V
Concentration in molarity equals moles of solute divided by volume of solution in liters. After converting grams to moles, use this to determine solution concentration.
Moles to Grams (Reverse)
m = n × M
Mass in grams equals moles multiplied by molar mass. The reverse calculation, useful for verifying your grams-to-moles conversion.
Molar Mass Reference Tables
Molar Masses of Common Elements and Compounds
Standard molar masses based on IUPAC atomic weights for frequently encountered substances in chemistry.
| Substance | Formula | Molar Mass (g/mol) | Category |
|---|---|---|---|
| Hydrogen | H₂ | 2.016 | Element (gas) |
| Oxygen | O₂ | 31.998 | Element (gas) |
| Carbon | C | 12.011 | Element (solid) |
| Iron | Fe | 55.845 | Element (metal) |
| Water | H₂O | 18.015 | Compound |
| Sodium Chloride | NaCl | 58.440 | Compound |
| Glucose | C₆H₁₂O₆ | 180.156 | Compound |
| Sulfuric Acid | H₂SO₄ | 98.079 | Compound |
| Ammonia | NH₃ | 17.031 | Compound |
| Acetic Acid | CH₃COOH | 60.052 | Compound |
Mole Concept Relationships
Key relationships connecting mass, moles, molecules, and volume for gases at STP (0°C, 1 atm).
| Relationship | Formula | Example (Water) |
|---|---|---|
| Mass ↔ Moles | n = m / M | 18.015 g ÷ 18.015 g/mol = 1 mol |
| Moles ↔ Molecules | N = n × Nₐ | 1 mol × 6.022 × 10²³ = 6.022 × 10²³ molecules |
| Moles ↔ Volume (gas, STP) | V = n × 22.414 L | 1 mol gas = 22.414 L at STP |
| Mass ↔ Molecules | N = (m / M) × Nₐ | 36.03 g H₂O = 1.204 × 10²⁴ molecules |
| Concentration ↔ Moles | n = C × V | 1 M × 0.5 L = 0.5 mol |
Worked Examples
Convert 100 g of Water to Moles
You have 100 grams of water (H₂O) and need to determine the number of moles for a chemistry calculation.
Determine molar mass of H₂O: M = 2(1.008) + 15.999 = 18.015 g/mol
Apply the formula: n = m / M = 100 g / 18.015 g/mol
Calculate: n = 5.551 mol
Verify: 5.551 mol × 18.015 g/mol = 99.99 g ≈ 100 g ✓
100 grams of water contains 5.551 moles of H₂O.
Find the Number of Molecules in 36 g of Water
You need to determine exactly how many water molecules are present in a 36-gram sample for a spectroscopy experiment.
Convert grams to moles: n = 36 g / 18.015 g/mol = 1.999 mol ≈ 2.0 mol
Apply Avogadro's number: N = 2.0 mol × 6.022 × 10²³ mol⁻¹
Calculate: N = 1.204 × 10²⁴ molecules
Cross-check atoms: Each H₂O has 3 atoms, so total atoms = 3 × 1.204 × 10²⁴ = 3.613 × 10²⁴
36 grams of water contains approximately 2.0 moles, which equals 1.204 × 10²⁴ water molecules (or 3.613 × 10²⁴ individual atoms).
Calculate Moles of NaCl for a 0.5 M Solution
You need to prepare 250 mL of a 0.5 M NaCl solution. First, find how many moles are needed, then convert to grams.
Calculate moles needed: n = C × V = 0.5 mol/L × 0.250 L = 0.125 mol
Convert to grams: m = n × M = 0.125 mol × 58.44 g/mol = 7.305 g
Weigh 7.305 g NaCl and dissolve in water to a final volume of 250 mL
Verify concentration: 7.305 g / 58.44 g/mol / 0.250 L = 0.5 mol/L ✓
Weigh 7.305 grams of NaCl and dissolve in water, bringing the total volume to 250 mL, to prepare a 0.5 M sodium chloride solution.
How to Use This Calculator
Choose a Calculation Mode
Click 'Grams → Moles' if you know the mass and want the mole count, or 'Moles → Grams' if you know the moles and need the mass. The input field switches automatically.
Enter the Chemical Formula
Type the chemical formula in the substance field (e.g., H2O for water, NaCl for salt, C6H12O6 for glucose). Or click one of the quick-select compound buttons. The molar mass is calculated automatically from the formula.
Enter the Mass or Moles
Type the known value — mass in grams (for Grams → Moles mode) or the number of moles (for Moles → Grams mode). Results update instantly as you type.
Read the Results
The main result shows moles or grams. Below that you will see molar mass, molecule count (in scientific notation), and an elemental composition bar chart showing each element's mass percentage in the compound.
Frequently Asked Questions
How do I convert grams to moles?
Divide the mass in grams by the molar mass of the substance (in g/mol). The formula is n = m / M, where n is moles, m is mass, and M is molar mass. For example, to convert 36 g of water (molar mass 18.015 g/mol) to moles: n = 36 / 18.015 ≈ 2.0 mol. This calculator does the division automatically as soon as you enter the formula and mass. The molar mass is computed by summing the atomic masses of all atoms in the formula — you do not need to look them up separately.
How do I convert moles to grams?
Multiply the number of moles by the molar mass: m = n × M. Switch the calculator to 'Moles → Grams' mode, enter your substance, then type the mole count. For example, 2.5 mol of NaCl (molar mass 58.44 g/mol) equals 2.5 × 58.44 = 146.1 g. This reverse calculation is just as common in the lab — for instance when you need to weigh out a specific number of moles for a reaction and need to know how many grams to put on the balance.
What is Avogadro's number and why does it appear in results?
Avogadro's number (Nₐ = 6.02214076 × 10²³) is the number of atoms, ions, or molecules in one mole of a substance. It provides a link between the macroscopic scale (grams) and the atomic scale (individual particles). Multiplying moles by Nₐ gives the number of molecules in your sample. For example, 1 mol of H₂O contains 6.022 × 10²³ water molecules. This figure is useful in physical chemistry, spectroscopy, and any context where you need to know the actual particle count rather than just the amount in moles.
What is molar mass and where do the values come from?
Molar mass is the mass of one mole of a substance, expressed in grams per mole (g/mol). For pure elements, the molar mass equals the standard atomic weight published by IUPAC, which is the weighted average of all naturally occurring isotopes. For compounds, it is the sum of the atomic weights of all atoms in the molecular formula. The atomic masses used in this calculator are based on the 2021 IUPAC standard atomic weights, rounded to three to four decimal places. For most lab and classroom purposes these values are accurate enough; for isotope-specific work, consult enriched-isotope data.
Can I use this for organic molecules like glucose or aspirin?
Yes. Enter the molecular formula in the substance field — for example C6H12O6 for glucose or C9H8O4 for aspirin. The parser reads each element symbol and its subscript count, multiplies by the atomic mass, and sums the contributions. The elemental composition chart will show the mass percentage of each element (carbon, hydrogen, oxygen) and how they add up to the total molar mass. This is useful for verifying empirical formulas and understanding mass fractions in organic chemistry or nutrition science.
What should I do if my compound is not recognised?
The formula parser supports 32 common elements. If you enter a formula containing an element outside this set, or a formula with parentheses (like Ca(OH)₂), the calculator will show an error. In that case, look up the molar mass from a reference source (e.g., PubChem or a CRC Handbook) and enter it in the 'Molar Mass Override' field. The calculator will then use your value for the conversion. This also works for mixtures, polymers, or any substance where the exact molecular formula is not available.
Related Tools
Moles to Grams Calculator
Convert moles to grams — the reverse operation using the same molar mass relationship.
Atomic Mass Calculator
Look up atomic masses and calculate molecular weights for determining molar mass of any compound.
Dilution Calculator
Use C₁V₁ = C₂V₂ to calculate dilution volumes after converting your sample mass to moles and concentration.
mg to Grams Converter
Convert milligrams to grams before performing mole calculations on small laboratory samples.
Percentage Calculator
Calculate mass percentages and composition ratios for elemental analysis and stoichiometry.