# Empirical Formula Calculator

> Converts the mass percentages (or masses) of each element into moles, divides by the smallest amount and scales to the smallest whole-number ratio to give the empirical formula; with a molar mass it also returns the molecular formula.

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

## Purpose

Converts the mass percentages (or masses) of each element into moles, divides by the smallest amount and scales to the smallest whole-number ratio to give the empirical formula; with a molar mass it also returns the molecular formula.

**Use when:** You have elemental analysis data (mass percent or grams of each element) and need the empirical formula, or the molecular formula when the compound's molar mass is known.

**Do not use when:** You start from a formula and need its percent composition or molar mass (use molar-mass), or the data are moles of each element already (write them as the counts directly).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `composition` | string_list |  | required | Element symbols each followed by its mass percent or mass in grams, e.g. ["C 40.0", "H 6.7", "O 53.3"] or the single string "C 40.0, H 6.7, O 53.3" (also C:40.0 or C=40.0). Symbols are case-sensitive. |
| `molar_mass_g_mol` | number | g/mol | optional | Molar mass of the compound (e.g. from mass spectrometry or colligative properties); when given, the molecular formula is derived. (> 0, max 10000000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `empirical_formula` | string |  | Simplest whole-number ratio of atoms, with the elements in the order they were entered. |
| `empirical_formula_mass_g_mol` | number | g/mol | Molar mass of one empirical formula unit. |
| `molecular_formula` | string |  | Empirical formula multiplied by molecular_multiplier (only when molar_mass_g_mol is given). |
| `molecular_multiplier` | integer |  | molar_mass_g_mol / empirical formula mass, rounded to the nearest integer. |
| `molecular_formula_mass_g_mol` | number | g/mol | Molar mass of the molecular formula found (compare with the input molar mass). |
| `ratio_multiplier` | integer |  | Factor applied to the mole ratios to reach whole numbers (e.g. 2 when a ratio ends in .5). |
| `elements` | list |  | Per element: symbol, mass (or percent) given, atomic weight, moles, ratio to the smallest and the subscript in the empirical formula. |
| `total_mass` | number |  | Sum of the values entered (should be about 100 for percentages). |

## Formula

`moles_i = mass_percent_i / atomic_weight_i; ratio_i = moles_i / min(moles); subscript_i = round(ratio_i × f) for the smallest integer f (1–12) that makes every ratio_i × f within 0.1 of an integer; n = round(molar_mass / empirical_formula_mass); molecular formula = (empirical formula)_n`

Percentages are treated as grams of a 100 g sample, so masses in grams give the same result. Atomic weights are the IUPAC 2021 abridged values; ratios that stay more than 0.1 from an integer for every multiplier up to 12 are rounded with the best multiplier and flagged in a note.

## Data Sources

- OpenStax Chemistry 2e – 3.2 Determining Empirical and Molecular Formulas — https://openstax.org/books/chemistry-2e/pages/3-2-determining-empirical-and-molecular-formulas (textbook, retrieved 2026-09-24)
- Wikipedia – Empirical formula — https://en.wikipedia.org/wiki/Empirical_formula (reference, retrieved 2026-09-24)
- 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-24)

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/empirical-formula?composition=…`
- `POST https://tttkmbb.com/api/v1/calculate/empirical-formula` 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/empirical-formula · OpenAPI operationId `calculate_empirical_formula` 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:  `run_calculator` with `{"calculator_id": "empirical-formula", "inputs": {…}}`

## Example

- C 40.0 %, H 6.7 %, O 53.3 %, molar mass 180.16: inputs `{"composition":["C 40.0","H 6.7","O 53.3"],"molar_mass_g_mol":180.16}` → `{"empirical_formula":"CH2O","empirical_formula_mass_g_mol":30.026,"molecular_formula":"C6H12O6","molecular_multiplier":6,"molecular_formula_mass_g_mol":180.156,"ratio_multiplier":1,"total_mass":100}`
- Hematite: Fe 69.94 %, O 30.06 %: inputs `{"composition":"Fe 69.94, O 30.06"}` → `{"empirical_formula":"Fe2O3","empirical_formula_mass_g_mol":159.687,"ratio_multiplier":2}`

```
GET https://tttkmbb.com/api/v1/calculate/empirical-formula?composition=C+40.0%2CH+6.7%2CO+53.3&molar_mass_g_mol=180.16
```

## Limitations

You start from a formula and need its percent composition or molar mass (use molar-mass), or the data are moles of each element already (write them as the counts directly). Percentages are treated as grams of a 100 g sample, so masses in grams give the same result. Atomic weights are the IUPAC 2021 abridged values; ratios that stay more than 0.1 from an integer for every multiplier up to 12 are rounded with the best multiplier and flagged in a note. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**My ratios come out as 1.33 or 1.5. What happens?**

The calculator multiplies all ratios by the smallest integer (3 or 2 here) that turns them into whole numbers, which is how Fe2O3 or C3H8 arise from 1 : 1.5 or 1 : 2.67 ratios.

**Can I enter grams instead of percentages?**

Yes. Only the ratios matter, so masses from a combustion analysis (e.g. grams of C, H and O) work directly; the sum of inputs is reported so you can check it.

**Why does the molecular formula mass differ slightly from my molar mass?**

The multiplier is rounded to an integer; the reported molecular_formula_mass_g_mol is the exact mass of the formula found. A multiplier far from an integer (flagged in a note) suggests an error in the data.

## Related

- [Molar Mass Calculator](https://tttkmbb.com/chemistry/molar-mass.md) — Percent composition and molar mass of the formula found.
- [Mass Percent Calculator](https://tttkmbb.com/chemistry/mass-percent.md) — Mass percent of a component in a mixture.
- [Moles to Grams Calculator](https://tttkmbb.com/chemistry/moles-mass.md) — Grams-to-moles conversion for one substance.
