Skip to main content

Molar mass calculator and moles to grams converter

Enter H2O, NaCl, Ca(OH)2 or CuSO4·5H2O. The tool parses the formula, calculates molar mass from CIAAW atomic weights and converts grams ↔ moles with n = m/M.

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Enter a chemical formula. You may then provide either a mass or an amount of substance to convert automatically in the other direction.

Examples: H2O, NaCl, Ca(OH)2, Al2(SO4)3, CuSO4·5H2O. Unicode subscripts such as H₂O are accepted.

Atomic weights use the CIAAW 2024 abridged standard values for normal materials. Samples with unusual isotopic composition can have a different molar mass.

Results

Molar mass (M)
-
Mass (m)
-
Amount of substance (n)
-

Formula breakdown

ElementAtom countAbridged atomic weightContribution to M (g/mol)

Calculation details

    Was this tool useful?

    How does this tool work?

    Molar mass connects a microscopic chemical formula with a mass that can be measured in the laboratory. Symbol M, it is the mass per mole of specified chemical entities. This calculator parses formulas such as H2O, NaCl, Ca(OH)2 and CuSO4·5H2O, counts each element and adds its atomic-weight contribution to obtain molar mass in g/mol. It then converts mass to amount of substance with n = m/M or performs the inverse calculation m = nM.

    The first step is formula parsing. Each element symbol is matched to a reference atomic weight and multiplied by the number of atoms in the formula. For H2O there are two hydrogen atoms and one oxygen atom, giving M ≈ 2 × 1.0080 + 15.999 = 18.015 g/mol.

    Atomic weights come from CIAAW's 2024 Abridged Standard Atomic Weights table. These recommended practical values are designed for routine chemical calculations while reflecting natural isotopic variability. The exact atomic weight of a particular sample can differ when its isotope composition is unusual.

    The parser handles multipliers after individual elements and grouped formulas. Ca(OH)2 contains one calcium, two oxygen atoms and two hydrogen atoms. Square brackets are also supported, for example K4[Fe(CN)6]. Hydrates can be written with a middle dot such as CuSO4·5H2O.

    Once M is known, mass m and amount of substance n are related by n = m/M. The inverse is m = nM. Entering mass calculates moles; entering mol, mmol or µmol calculates the corresponding mass.

    IUPAC defines molar mass as mass divided by amount of substance. The coherent SI unit is kg/mol, while g/mol is standard practical chemistry usage and has the useful property that its numerical value matches relative molar mass when standard atomic weights are used.

    The result belongs to the exact formula entered. It does not infer sample purity, solution composition or hydration state. An anhydrous salt and its hydrate have different molar masses, so CuSO4 and CuSO4·5H2O must be treated as distinct formulas.

    For elements with no CIAAW standard atomic weight, including several radioactive or synthetic elements, this tool intentionally refuses to invent a value from an isotope mass number. That keeps the data source explicit and the result scientifically interpretable.

    How to use this tool

    1. Enter the formula

      Use proper element capitalization such as NaCl, not NACL. Standard digits and Unicode subscripts are accepted.

    2. Review the composition

      The table shows each element, atom count, abridged atomic weight and contribution to total molar mass.

    3. Optionally enter mass or moles

      Fill only one value. The other is calculated automatically using n = m/M or m = nM.

    4. Check units

      mg, g, kg, oz, lb, µmol, mmol and mol conversions use Bethemesh's shared unit engine.

    Molar mass and moles ↔ mass formulas

    Formula composition determines molar mass, which then connects mass and amount of substance.

    Formula molar mass

    M = Σ(Nᵢ × Aᵢ)

    Sum each atomic weight Aᵢ multiplied by the count Nᵢ of that element.

    Amount of substance

    n = m ÷ M

    Amount of substance equals mass divided by molar mass.

    Mass

    m = n × M

    Mass equals amount of substance multiplied by molar mass.

    M
    molar mass of the compound, commonly in g/mol
    Nᵢ
    number of atoms of element i in the formula
    Aᵢ
    abridged standard atomic weight of element i
    n
    amount of substance in mol
    m
    sample mass

    Atomic weights use CIAAW 2024 abridged standard values for normal materials. A specific isotope composition can change the actual value.

    Use cases

    Chemistry exercises

    Calculate formula molar masses and verify atom counting step by step.

    Solution preparation

    Determine a mass to weigh from a target amount before a concentration calculation.

    Stoichiometry

    Convert experimental masses to moles before applying balanced-reaction coefficients.

    Formula checking

    Inspect contributions in simple compounds, grouped formulas, salts and hydrates.

    Examples

    Water H2O

    2 H + 1 O: 2 × 1.0080 + 15.999.

    Input

    H2O

    Result

    M ≈ 18.015 g/mol

    Sodium chloride NaCl

    22.990 + 35.45 ≈ 58.44 g/mol.

    Input

    NaCl

    Result

    M ≈ 58.44 g/mol

    Calcium hydroxide

    The OH group is multiplied by two.

    Input

    Ca(OH)2

    Result

    M ≈ 74.092 g/mol

    Mass to moles

    n = 18.015 / 18.015.

    Input

    18.015 g H2O

    Result

    ≈ 1 mol

    Moles to mass

    m = 0.5 × 58.44.

    Input

    0.5 mol NaCl

    Result

    ≈ 29.22 g

    Hydrate

    The parser adds CuSO4 and five water units.

    Input

    CuSO4·5H2O

    Result

    M ≈ 249.68 g/mol

    Tips and best practices

    • Element capitalization matters: CO is carbon plus oxygen, while Co is cobalt.
    • A multiplier after parentheses applies to the whole group.
    • Include water of crystallization explicitly when working with a hydrate.
    • Do not substitute an isotope mass number for a standard atomic weight unless the problem explicitly concerns that isotope.
    • Divide mmol by 1000 to obtain mol; divide µmol by one million.
    • Molar mass alone does not correct for reagent purity. Apply purity or assay factors separately when required.
    • Keep additional digits during calculations and round according to the precision of the input data.

    Sources and references

    Frequently asked questions

    How do I calculate molar mass?

    Add the atomic-weight contributions of every atom in the formula, including subscripts and group multipliers.

    What formula converts grams to moles?

    Use n = m/M, where m is mass and M is molar mass.

    How do I convert moles to grams?

    Use m = nM.

    What unit should molar mass use?

    g/mol is common in chemistry. The coherent SI unit is kg/mol.

    Does the parser support parentheses?

    Yes, including formulas such as Ca(OH)2 and Al2(SO4)3, plus square brackets.

    Are hydrate formulas supported?

    Yes. For example, CuSO4·5H2O can use a middle dot or ordinary dot between formula parts.

    Why can published molar masses differ slightly?

    Some elements show natural isotopic variation. CIAAW publishes standard values and intervals; this calculator uses the recommended abridged values for routine work.

    Are molar mass and molecular weight the same?

    Molar mass has units such as g/mol. Relative molecular or molar mass is dimensionless, although the numerical values coincide when g/mol is used with standard atomic weights.

    Are my data sent to a server?

    No. Formula parsing and conversions run locally in your browser.

    Related tools

    Tools similar or complementary to this one.

    Similar tools

    Convert length, weight, volume, temperature, pressure, energy, fuel economy, digital storage and electrical units with exact factors.

    ScienceFeaturedUse this tool