# Ideal Gas Law Calculator

> Solves the ideal gas equation PV = nRT for whichever of pressure, volume, amount or temperature is left empty, with pressure in atm, kPa, bar, mmHg or psi and temperature in °C, K or °F.

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

## Purpose

Solves the ideal gas equation PV = nRT for whichever of pressure, volume, amount or temperature is left empty, with pressure in atm, kPa, bar, mmHg or psi and temperature in °C, K or °F.

**Use when:** You know three of pressure, volume, moles and temperature of a gas and need the fourth, or the molar volume at given conditions.

**Do not use when:** The gas is near condensation or at very high pressure (use a real-gas equation such as van der Waals), or you need the mass of gas without knowing its molar mass (combine with moles-mass).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `pressure` | number |  | optional | Gas pressure in the unit given by pressure_unit. Leave empty to solve for it. (> 0) |
| `pressure_unit` | enum: atm \| kpa \| bar \| mmhg \| psi |  | optional, default "atm" | Unit of the pressure input (1 atm = 101.325 kPa = 1.01325 bar = 760 mmHg = 14.696 psi). |
| `volume_l` | number | L | optional | Gas volume in litres. Leave empty to solve for it. (> 0) |
| `moles` | number | mol | optional | Amount of gas in moles. Leave empty to solve for it. (> 0) |
| `temperature` | number |  | optional | Gas temperature in the unit given by temperature_unit (must be above absolute zero). Leave empty to solve for it. (min -459.67, max 10000000) |
| `temperature_unit` | enum: celsius \| kelvin \| fahrenheit |  | optional, default "celsius" | Unit of the temperature input; the calculation uses kelvin. |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `solved_for` | string |  | pressure, volume_l, moles or temperature. |
| `pressure_atm` | number | atm | Pressure in standard atmospheres. |
| `pressure_kpa` | number | kPa | Pressure in kilopascals (1 atm = 101.325 kPa). |
| `pressure_bar` | number | bar | Pressure in bar (1 atm = 1.01325 bar). |
| `volume_l` | number | L | Gas volume in litres. |
| `moles` | number | mol | Amount of gas. |
| `temperature_k` | number | K | Absolute temperature. |
| `temperature_c` | number | °C | Temperature in degrees Celsius. |
| `molar_volume_l_per_mol` | number | L/mol | V / n at these conditions (22.414 L/mol at 0 °C and 1 atm). |

## Formula

`P × V = n × R × T with R = 0.082057366 L·atm/(mol·K) (= 8.314462618 J/(mol·K)); P converted to atm, T to kelvin (K = °C + 273.15)`

Ideal-gas behaviour is accurate to about 1% for common gases near room temperature and pressures up to a few atmospheres; deviations grow near the boiling point and above roughly 10 atm.

## Data Sources

- NIST – CODATA internationally recommended values of the fundamental physical constants (molar gas constant R = 8.314462618 J/(mol·K), exact) — https://physics.nist.gov/cuu/Constants/index.html (standard, retrieved 2026-09-23)
- OpenStax Chemistry 2e – 9.2 Relating Pressure, Volume, Amount, and Temperature: The Ideal Gas Law — https://openstax.org/books/chemistry-2e/pages/9-2-relating-pressure-volume-amount-and-temperature-the-ideal-gas-law (textbook, retrieved 2026-09-23)
- Wikipedia – Ideal gas law — https://en.wikipedia.org/wiki/Ideal_gas_law (reference, 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/ideal-gas-law?`
- `POST https://tttkmbb.com/api/v1/calculate/ideal-gas-law` 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/ideal-gas-law · OpenAPI operationId `solve_ideal_gas_law` 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": "ideal-gas-law", "inputs": {…}}`

## Example

- Molar volume at 0 °C and 1 atm: inputs `{"pressure":1,"pressure_unit":"atm","moles":1,"temperature":0,"temperature_unit":"celsius"}` → `{"solved_for":"volume_l","volume_l":22.414,"molar_volume_l_per_mol":22.414,"temperature_k":273.15,"pressure_kpa":101.325}`
- Moles in 5 L at 101.325 kPa and 25 °C: inputs `{"pressure":101.325,"pressure_unit":"kpa","volume_l":5,"temperature":25}` → `{"solved_for":"moles","moles":0.20437,"pressure_atm":1,"temperature_k":298.15,"molar_volume_l_per_mol":24.4654}`

```
GET https://tttkmbb.com/api/v1/calculate/ideal-gas-law?pressure=1&pressure_unit=atm&moles=1&temperature=0&temperature_unit=celsius
```

## Limitations

The gas is near condensation or at very high pressure (use a real-gas equation such as van der Waals), or you need the mass of gas without knowing its molar mass (combine with moles-mass). Ideal-gas behaviour is accurate to about 1% for common gases near room temperature and pressures up to a few atmospheres; deviations grow near the boiling point and above roughly 10 atm. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why is the molar volume 22.414 L and not 22.7 L?**

22.414 L/mol applies at 0 °C and 1 atm (101.325 kPa). IUPAC's current STP is 0 °C and 1 bar (100 kPa), which gives 22.711 L/mol; enter pressure 1 bar to reproduce it.

**Can I enter temperature in Celsius?**

Yes, temperature_unit defaults to celsius and the value is converted to kelvin internally; temperatures at or below absolute zero are rejected.

## Related

- [Moles to Grams Calculator](https://tttkmbb.com/chemistry/moles-mass.md) — Convert the moles of gas to mass or number of molecules.
- [Pressure Converter](https://tttkmbb.com/conversion/pressure.md) — Pressure expressed in Pa, kPa, bar, psi and atm (or from force and area).
- [Temperature Converter](https://tttkmbb.com/conversion/temperature.md) — Convert between Celsius, Fahrenheit and kelvin.
