# Molar Mass Calculator

> Parses a chemical formula (including brackets, nested groups and hydrates) and sums IUPAC 2021 standard atomic weights to give the molar mass in g/mol, plus the atom count and mass-percent composition of each element.

- Calculator id: `molar-mass` · Category: Chemistry (`chemistry`) · Tool name: `calculate_molar_mass`
- Canonical page: https://tttkmbb.com/chemistry/molar-mass · This document: https://tttkmbb.com/chemistry/molar-mass.md · JSON definition: https://tttkmbb.com/chemistry/molar-mass.json

## Purpose

Parses a chemical formula (including brackets, nested groups and hydrates) and sums IUPAC 2021 standard atomic weights to give the molar mass in g/mol, plus the atom count and mass-percent composition of each element.

**Use when:** You have a chemical formula and need its molar mass (molecular weight), the number of atoms of each element, or its elemental mass-percent composition.

**Do not use when:** You already know the molar mass and want to convert between grams and moles (use moles-mass) or need a solution concentration (use molarity).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `formula` | string |  | required | Chemical formula with case-sensitive element symbols, integer subscripts, brackets and optional hydrate dot, e.g. C6H12O6, Ca(OH)2, Fe2(SO4)3, CuSO4·5H2O. A trailing charge (NH4+, SO4^2-) or state (aq) is ignored. |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `molar_mass_g_mol` | number | g/mol | Sum of atomic weight × atom count over all elements. |
| `molecular_mass_da` | number | Da | Same value expressed in daltons (unified atomic mass units) per molecule or formula unit. |
| `atom_count` | integer |  | Total number of atoms in one formula unit. |
| `element_count` | integer |  | Number of distinct elements in the formula. |
| `composition` | list |  | Per element: symbol, atom count, atomic weight, contributed mass (g/mol) and mass fraction in percent. |

## Formula

`molar_mass = Σ (atomic_weight_i × count_i); mass_fraction_percent_i = 100 × atomic_weight_i × count_i / molar_mass`

Atomic weights are the IUPAC 2021 abridged standard values (conventional values for elements whose weight is given as an interval, e.g. H 1.008, C 12.011, O 15.999, S 32.06, Cl 35.45); the result is therefore reproducible to 3 decimals but not identical to tables using more digits. Radioactive elements without a standard atomic weight use the mass number of their longest-lived isotope.

## Data Sources

- IUPAC – Atomic Weights of the Elements (2021 table with 2023 revisions, Queen Mary University of London mirror) — https://iupac.qmul.ac.uk/AtWt/ (standard, retrieved 2026-09-23)
- CIAAW – Standard atomic weights (current values) — https://www.ciaaw.org/atomic-weights.htm (standard, retrieved 2026-09-23)
- OpenStax Chemistry 2e – 3.1 Formula Mass and the Mole Concept — https://openstax.org/books/chemistry-2e/pages/3-1-formula-mass-and-the-mole-concept (textbook, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/molar-mass?formula=…`
- `POST https://tttkmbb.com/api/v1/calculate/molar-mass` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/molar-mass · OpenAPI operationId `calculate_molar_mass` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool: `calculate_molar_mass` (dedicated) or `run_calculator` with `{"calculator_id": "molar-mass", "inputs": {…}}`

## Example

- Glucose C6H12O6: inputs `{"formula":"C6H12O6"}` → `{"molar_mass_g_mol":180.156,"atom_count":24,"element_count":3,"composition":[{"element":"C","count":6,"mass_fraction_percent":40.002},{"element":"H","count":12,"mass_fraction_percent":6.714},{"element":"O","count":6,"mass_fraction_percent":53.284}]}`
- Copper(II) sulfate pentahydrate CuSO4·5H2O: inputs `{"formula":"CuSO4·5H2O"}` → `{"molar_mass_g_mol":249.677,"atom_count":21,"element_count":4}`

```
GET https://tttkmbb.com/api/v1/calculate/molar-mass?formula=C6H12O6
```

## Limitations

You already know the molar mass and want to convert between grams and moles (use moles-mass) or need a solution concentration (use molarity). Atomic weights are the IUPAC 2021 abridged standard values (conventional values for elements whose weight is given as an interval, e.g. H 1.008, C 12.011, O 15.999, S 32.06, Cl 35.45); the result is therefore reproducible to 3 decimals but not identical to tables using more digits. Radioactive elements without a standard atomic weight use the mass number of their longest-lived isotope. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Which atomic weights are used?**

IUPAC 2021 standard atomic weights abridged to five significant figures (H 1.008, C 12.011, N 14.007, O 15.999, Na 22.990, Cl 35.45, Fe 55.845). Textbooks using more digits or older tables may differ in the third decimal.

**Can I enter ions, hydrates or states?**

Yes: NH4+, NO3-, SO4^2- or 'CO3 2-' drop the charge (electron mass is negligible), CuSO4·5H2O (also written CuSO4.5H2O or CuSO4*5H2O) adds five waters, and (aq)/(s)/(l)/(g) is ignored. Write multi-digit charges as Fe^3+ or 'Fe 3+', because Fe3+ is read as three iron atoms.

**Why is my formula rejected?**

Element symbols are case-sensitive (Co ≠ CO, nacl is invalid), subscripts must be positive integers, and every opening bracket needs a closing one. Structural notation such as CH3-CH2-OH is not parsed; write C2H6O instead.

## Related

- [Moles to Grams Calculator](https://tttkmbb.com/chemistry/moles-mass.md) — Convert grams of this substance to moles and number of molecules.
- [Molarity Calculator](https://tttkmbb.com/chemistry/molarity.md) — Turn a mass of this compound into a solution concentration.
- [Mass Percent Calculator](https://tttkmbb.com/chemistry/mass-percent.md) — Mass percent of a solute in a solution rather than of an element in a compound.
