How to Calculate the Molar Mass

Molar Mass Calculator

Use this calculator to determine the molar mass of any chemical compound by entering its chemical formula. Molar mass is a fundamental property in chemistry, essential for stoichiometry, preparing solutions, and understanding chemical reactions.

What is Molar Mass?

Molar mass (M) is defined as the mass of one mole of a substance. It is typically expressed in grams per mole (g/mol). For a chemical compound, the molar mass is the sum of the atomic masses of all the atoms in its chemical formula. For example, the molar mass of water (H₂O) is the sum of the atomic masses of two hydrogen atoms and one oxygen atom.

Why is Molar Mass Important?

  • Stoichiometry: It's crucial for converting between mass and moles in chemical reactions.
  • Solution Preparation: Used to calculate the amount of solute needed to achieve a desired concentration.
  • Chemical Analysis: Helps in identifying unknown substances and determining empirical and molecular formulas.

How to Use the Molar Mass Calculator

  1. Enter the chemical formula of the compound into the "Chemical Formula" field.
  2. Ensure correct capitalization for element symbols (e.g., "H" for hydrogen, "He" for helium, "Na" for sodium).
  3. Use numbers for subscripts (e.g., "H2O" for water, "C6H12O6" for glucose).
  4. For groups of atoms repeated multiple times, use parentheses (e.g., "Al2(SO4)3" for aluminum sulfate, "Fe(OH)3" for iron(III) hydroxide).
  5. Click the "Calculate Molar Mass" button.
  6. The molar mass will be displayed in grams per mole (g/mol).

Examples:

  • Water: H2O (18.015 g/mol)
  • Glucose: C6H12O6 (180.156 g/mol)
  • Sulfuric Acid: H2SO4 (98.079 g/mol)
  • Aluminum Sulfate: Al2(SO4)3 (342.15 g/mol)
// Atomic masses from IUPAC (rounded to 3-4 decimal places for common elements) var atomicMasses = { "H": 1.008, "He": 4.0026, "Li": 6.94, "Be": 9.0122, "B": 10.81, "C": 12.011, "N": 14.007, "O": 15.999, "F": 18.998, "Ne": 20.180, "Na": 22.990, "Mg": 24.305, "Al": 26.982, "Si": 28.085, "P": 30.974, "S": 32.06, "Cl": 35.45, "Ar": 39.948, "K": 39.098, "Ca": 40.078, "Sc": 44.956, "Ti": 47.867, "V": 50.942, "Cr": 51.996, "Mn": 54.938, "Fe": 55.845, "Co": 58.933, "Ni": 58.693, "Cu": 63.546, "Zn": 65.38, "Ga": 69.723, "Ge": 72.63, "As": 74.922, "Se": 78.971, "Br": 79.904, "Kr": 83.798, "Rb": 85.468, "Sr": 87.62, "Y": 88.906, "Zr": 91.224, "Nb": 92.906, "Mo": 95.95, "Tc": 98, "Ru": 101.07, "Rh": 102.91, "Pd": 106.42, "Ag": 107.87, "Cd": 112.41, "In": 114.82, "Sn": 118.71, "Sb": 121.76, "I": 126.90, "Te": 127.60, "Xe": 131.29, "Cs": 132.91, "Ba": 137.33, "La": 138.91, "Ce": 140.12, "Pr": 140.91, "Nd": 144.24, "Pm": 145, "Sm": 150.36, "Eu": 151.96, "Gd": 157.25, "Tb": 158.93, "Dy": 162.50, "Ho": 164.93, "Er": 167.26, "Tm": 168.93, "Yb": 173.05, "Lu": 174.97, "Hf": 178.49, "Ta": 180.95, "W": 183.84, "Re": 186.21, "Os": 190.23, "Ir": 192.22, "Pt": 195.08, "Au": 196.97, "Hg": 200.59, "Tl": 204.38, "Pb": 207.2, "Bi": 208.98, "Po": 209, "At": 210, "Rn": 222, "Fr": 223, "Ra": 226, "Ac": 227, "Pa": 231.04, "Th": 232.04, "Np": 237, "U": 238.03, "Am": 243, "Pu": 244, "Cm": 247, "Bk": 247, "Cf": 251, "Es": 252, "Fm": 257, "Md": 258, "No": 259, "Rf": 261, "Lr": 262, "Db": 262, "Bh": 264, "Sg": 266, "Mt": 268, "Rg": 272, "Hs": 277 }; function parseFormula(formula) { var elements = {}; var stack = [elements]; // Stack to hold element counts for current scope var i = 0; var len = formula.length; var openParentheses = 0; // Track open parentheses for error checking while (i < len) { var char = formula[i]; if (char === '(') { stack.push({}); // New scope for elements inside parentheses openParentheses++; i++; } else if (char === ')') { if (openParentheses === 0) { throw new Error("Mismatched parentheses: closing parenthesis without opening."); } openParentheses–; i++; var multiplier = 1; if (i < len && /\d/.test(formula[i])) { var numStr = ''; while (i < len && /\d/.test(formula[i])) { numStr += formula[i]; i++; } multiplier = parseInt(numStr); } var poppedElements = stack.pop(); var currentScope = stack[stack.length – 1]; for (var el in poppedElements) { if (poppedElements.hasOwnProperty(el)) { currentScope[el] = (currentScope[el] || 0) + poppedElements[el] * multiplier; } } } else if (/[A-Z]/.test(char)) { var elementSymbol = char; i++; if (i < len && /[a-z]/.test(formula[i])) { elementSymbol += formula[i]; i++; } var count = 1; if (i < len && /\d/.test(formula[i])) { var numStr = ''; while (i 0) { throw new Error("Mismatched parentheses: opening parenthesis without closing."); } return stack[0]; // The final accumulated elements } function calculateMolarMass() { var formulaInput = document.getElementById("chemicalFormula").value.trim(); var resultDiv = document.getElementById("molarMassResult"); resultDiv.innerHTML = ""; // Clear previous results if (formulaInput === "") { resultDiv.innerHTML = "Please enter a chemical formula."; return; } try { var parsedElements = parseFormula(formulaInput); var totalMolarMass = 0; var unknownElements = []; for (var elementSymbol in parsedElements) { if (parsedElements.hasOwnProperty(elementSymbol)) { var count = parsedElements[elementSymbol]; if (atomicMasses[elementSymbol]) { totalMolarMass += atomicMasses[elementSymbol] * count; } else { unknownElements.push(elementSymbol); } } } if (unknownElements.length > 0) { resultDiv.innerHTML = "Error: Unknown element symbol(s) found: " + unknownElements.join(", ") + ". Please check your formula."; } else if (totalMolarMass > 0) { resultDiv.innerHTML = "Molar Mass: " + totalMolarMass.toFixed(3) + " g/mol"; } else { resultDiv.innerHTML = "Could not calculate molar mass. Please check the formula for errors."; } } catch (error) { resultDiv.innerHTML = "Error: " + error.message + ""; } }

Leave a Comment