# Molarity Calculator

> Computes molar concentration (mol/L) of a solution from the amount of solute (moles, or mass with a formula or molar mass) and the solution volume, or the moles and mass of solute needed to prepare a target molarity.

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

## Purpose

Computes molar concentration (mol/L) of a solution from the amount of solute (moles, or mass with a formula or molar mass) and the solution volume, or the moles and mass of solute needed to prepare a target molarity.

**Use when:** You need the molarity of a solution from what was dissolved, or the grams of solute required for a given volume and target concentration.

**Do not use when:** You are diluting an existing stock solution (use dilution), or you need a mass-based concentration such as % w/w, ppm or ppb (use mass-percent).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `volume_l` | number | L | required | Total volume of the solution in litres (250 mL = 0.25). (> 0) |
| `moles` | number | mol | optional | Amount of solute in moles. Takes precedence over mass_g. (> 0) |
| `mass_g` | number | g | optional | Mass of solute in grams; requires formula or molar_mass_g_mol. (> 0) |
| `formula` | string |  | optional | Chemical formula, e.g. NaCl, C6H12O6, Ca(OH)2 or CuSO4·5H2O (case-sensitive element symbols). Alternative to molar_mass_g_mol. |
| `molar_mass_g_mol` | number | g/mol | optional | Molar mass of the substance; use instead of formula when it is already known. (> 0, max 10000000) |
| `target_molarity_mol_per_l` | number | mol/L | optional | Desired concentration; when given, the calculator returns the moles and mass of solute needed for volume_l instead (moles and mass_g are ignored). (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `molarity_mol_per_l` | number | mol/L | Moles of solute per litre of solution (M). |
| `millimolar` | number | mmol/L | Same concentration in millimoles per litre (mM). |
| `moles` | number | mol | Amount of solute in the solution. |
| `mass_g` | number | g | Mass of solute (only when the molar mass is known). |
| `molar_mass_g_mol` | number | g/mol | Molar mass used (only when formula or molar_mass_g_mol was given). |
| `mass_concentration_g_per_l` | number | g/L | Grams of solute per litre of solution (only when the molar mass is known). |
| `volume_ml` | number | mL | Solution volume in millilitres. |
| `solved_for` | string |  | molarity_mol_per_l when computing a concentration, mass_g when computing what to weigh for a target molarity. |

## Formula

`molarity = moles / volume_l, with moles = mass_g / molar_mass_g_mol; for a target: moles = target_molarity × volume_l and mass_g = moles × molar_mass_g_mol`

Molarity refers to the final volume of solution, not the volume of solvent added; volume changes with temperature, so molarity is usually stated at 20–25 °C.

## Data Sources

- OpenStax Chemistry 2e – 3.3 Molarity — https://openstax.org/books/chemistry-2e/pages/3-3-molarity (textbook, retrieved 2026-09-23)
- Wikipedia – Molar concentration — https://en.wikipedia.org/wiki/Molar_concentration (reference, retrieved 2026-09-23)
- 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)

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/molarity?volume_l=…`
- `POST https://tttkmbb.com/api/v1/calculate/molarity` 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/molarity · OpenAPI operationId `calculate_molarity` 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": "molarity", "inputs": {…}}`

## Example

- 5.844 g NaCl in 0.5 L: inputs `{"volume_l":0.5,"mass_g":5.844,"formula":"NaCl"}` → `{"molarity_mol_per_l":0.2,"millimolar":200,"moles":0.1,"molar_mass_g_mol":58.44,"mass_concentration_g_per_l":11.688,"solved_for":"molarity_mol_per_l"}`
- Prepare 250 mL of 0.1 M NaOH: inputs `{"volume_l":0.25,"target_molarity_mol_per_l":0.1,"formula":"NaOH"}` → `{"moles":0.025,"mass_g":0.9999,"molar_mass_g_mol":39.997,"molarity_mol_per_l":0.1,"solved_for":"mass_g"}`

```
GET https://tttkmbb.com/api/v1/calculate/molarity?volume_l=0.5&mass_g=5.844&formula=NaCl
```

## Limitations

You are diluting an existing stock solution (use dilution), or you need a mass-based concentration such as % w/w, ppm or ppb (use mass-percent). Molarity refers to the final volume of solution, not the volume of solvent added; volume changes with temperature, so molarity is usually stated at 20–25 °C. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Is the volume the water added or the final solution?**

The final solution volume. Dissolve the solute in less solvent than needed, then make up to the mark in a volumetric flask.

**What if I know the mass but not the formula?**

Enter molar_mass_g_mol instead of formula. Without either, only moles can be used to compute molarity.

## Related

- [Dilution Calculator](https://tttkmbb.com/chemistry/dilution.md) — Dilute the resulting stock to a lower concentration with C1V1 = C2V2.
- [Molar Mass Calculator](https://tttkmbb.com/chemistry/molar-mass.md) — Check the molar mass used for the mass-to-moles conversion.
- [Moles to Grams Calculator](https://tttkmbb.com/chemistry/moles-mass.md) — Plain gram/mole conversion without a volume.
