Ideal Gas Law Calculator

Solve PV = nRT for any one of pressure, volume, amount, or temperature using the exact CODATA molar gas constant, or switch to density mode for ρ = P·M/(R·T) with verified molar-mass presets for air, nitrogen, oxygen, carbon dioxide, and methane.


CODATA 2018 (exact R) · IUPAC/CIAAW 2021 · NIST air molar mass

Mode

R = 8.314462618 J/(mol·K) — exact since the 2019 SI redefinition (CODATA). Pressure is absolute (1 atm = 101.325 kPa); temperature converts to kelvin internally.

Gas State (enter the known three)

kPa
mol
°C

The solved variable is hidden from the inputs. Enter gauge readings as absolute: gauge + 101.325 kPa at sea level.

Solved Gas State

22.414L
0.022414 m³
101.33kPa
P (absolute)
22.414L
V
1mol
n
273.15K
T

Complete state via PV = nRT with R = 8.314462618 J/(mol·K). Ideal-gas accuracy is ~1% for common gases near ambient conditions; apply a compressibility factor Z near condensation or above ~10 bar.

About Ideal Gas Law Calculator — Solve PV = nRT & Gas Density

The ideal gas law calculator solves PV = nRT — the equation of state that ties a gas's absolute pressure P, volume V, amount n (in moles), and absolute temperature T together through the molar gas constant R = 8.314462618 J/(mol·K), a value that has been exact since the 2019 SI redefinition fixed the Boltzmann and Avogadro constants (CODATA). Pick the variable to solve for, enter the other three, and the tool returns the complete gas state: the classic check is one mole at 0 °C and 1 atm occupying 22.414 L, the CODATA molar volume of an ideal gas.

The second mode answers the question process and HVAC work actually asks most: what does this gas weigh? Density follows directly from the same law as ρ = P·M/(R·T), where M is the molar mass. The tool ships verified presets — dry air at 28.97 g/mol (the engineering rounding of NIST's 28.9647), N₂ 28.014, O₂ 31.998, CO₂ 44.009, and CH₄ 16.043 from IUPAC/CIAAW 2021 conventional atomic weights — or takes any custom molar mass, and reports the density in kg/m³ together with the molar concentration and molar volume. The ideal-gas model is accurate to about a percent for these gases near ambient conditions; expect drift near condensation or at high pressures where a compressibility factor Z is needed.

How It Works

  1. Choose the mode. "Solve PV = nRT" finds any one state variable from the other three; "Gas density" computes ρ, n/V, and molar volume from pressure, temperature, and molar mass.
  2. Enter pressure in kilopascals (absolute, not gauge — add atmospheric pressure to a gauge reading first; 1 atm = 101.325 kPa) and temperature in °C, which the tool converts to kelvin internally. Temperatures at or below absolute zero are rejected, not silently clamped.
  3. In solve mode, pick the variable to find. The remaining three inputs stay visible; the solved value is reported in SI (Pa, m³, mol, K) with everyday companions — kPa and atm for pressure, liters for volume, °C for temperature.
  4. In density mode, pick a preset gas or enter a custom molar mass in g/mol — for mixtures, use the mole-fraction-weighted average, which is exactly how dry air's 28.97 g/mol arises from ~78% N₂, 21% O₂, and 1% Ar.
  5. Read the results and sanity-check against the anchors: 22.414 L/mol at 0 °C and 1 atm, and dry air at 1.204 kg/m³ at 20 °C and 1 atm. If your conditions are near a boiling point or above ~10 bar, treat the output as a first estimate and reach for real-gas properties.

Worked Example

Find the volume of one mole of an ideal gas at standard conditions — 0 °C (273.15 K) and 1 atm (101.325 kPa). Solving PV = nRT for V: V = nRT/P = 1 × 8.314462618 × 273.15 / 101325 = 0.0224140 m³ = 22.414 L, the CODATA molar volume of an ideal gas at STP. Switching to density mode with the same conditions and the dry-air preset (M = 28.97 g/mol): ρ = P·M/(R·T) = 101325 × 0.02897 / (8.314462618 × 273.15) = 1.2925 kg/m³ — and re-running at 20 °C gives 1.204 kg/m³, the textbook room-temperature air density.

Gas density at standard conditions

Densities of five common gases at 1 atm (101.325 kPa) from ρ = P·M/(R·T), at 0 °C and 25 °C — enter the same pressure and temperature in density mode to reproduce any cell. Molar masses are the tool's verified presets: dry air per NIST (28.9647, rounded 28.97 g/mol), the rest from IUPAC/CIAAW 2021 conventional atomic weights.

GasMolar mass (g/mol)Density at 0 °C (kg/m³)Density at 25 °C (kg/m³)
Air (dry)28.971.29251.1841
Nitrogen (N₂)28.0141.24981.1450
Oxygen (O₂)31.9981.42761.3079
Carbon dioxide (CO₂)44.0091.96351.7988
Methane (CH₄)16.0430.71580.6557

Formulas

Ideal gas law
P·V = n·R·T
Solved forms
P = nRT/V; V = nRT/P; n = PV/(RT); T = PV/(nR)
Gas density
ρ = P·M / (R·T)

Standards & References

  • CODATA 2018 (post-2019 SI redefinition): R = N_A·k = 8.314462618 J/(mol·K) exactly; molar volume of ideal gas at 273.15 K, 101.325 kPa = 22.41397 L/mol
  • Molar masses: dry air 28.9647 g/mol (U.S. Standard Atmosphere 1976 / NIST), rounded to the engineering convention 28.97; N₂, O₂, CO₂, CH₄ from IUPAC/CIAAW 2021 conventional atomic weights
  • Ideal-gas assumption: accurate to ~1% for these gases near ambient conditions; use a compressibility factor Z near condensation or at elevated pressure

Frequently Asked Questions

What value of R should I use in PV = nRT?

R = 8.314462618 J/(mol·K) when pressure is in pascals, volume in cubic meters, and temperature in kelvin — this SI value is exact, because the 2019 SI redefinition fixed both the Avogadro and Boltzmann constants and R is their product. Other textbook values (0.082057 L·atm/(mol·K), 10.732 ft³·psi/(lb-mol·°R)) are the same constant in different units. The calculator works in SI internally and converts your kPa, liter, and °C entries for you.

Do I enter gauge or absolute pressure?

Absolute, always. The gas law is a relation between absolute quantities: a tire gauge reading 220 kPa at sea level is about 321 kPa absolute (gauge + 101.325 kPa atmospheric). Using gauge pressure understates the true state and every derived quantity — a common source of ~30% density errors near ambient pressure. The same rule applies to temperature: kelvin, never °C, which is why the tool converts and rejects anything at or below absolute zero.

How accurate is the ideal gas law for real gases?

For air, N₂, O₂, and CH₄ near room conditions, within about 0.1–1% — the compressibility factor Z stays within a fraction of a percent of 1. CO₂ deviates a bit more (Z ≈ 0.995 at 1 atm, 0 °C). The model degrades close to the saturation (condensation) point and at high pressure: at 50 bar and 0 °C, CO₂'s error reaches tens of percent. When that matters, multiply the right side by Z from real-gas data: PV = ZnRT.

Why is the density of air 1.2 kg/m³, and when does it change?

At 20 °C and 1 atm, ρ = 101325 × 0.02897 / (8.314462618 × 293.15) = 1.204 kg/m³. It scales linearly with absolute pressure and inversely with absolute temperature: at Denver's ~83 kPa the same air is about 0.99 kg/m³, and heating a room from 0 °C to 25 °C thins the air by 8%. Humidity lowers density slightly (water vapor's 18.015 g/mol displaces heavier N₂ and O₂) — moist air is lighter than dry air, not heavier.

What molar mass do I use for a gas mixture?

The mole-fraction-weighted average of the component molar masses: M_mix = Σ yᵢ·Mᵢ. Dry air is the canonical example — 0.7808 × 28.014 (N₂) + 0.2095 × 31.998 (O₂) + 0.0093 × 39.95 (Ar) + minor gases ≈ 28.96 g/mol, which is exactly where the air preset's 28.97 comes from. Enter the weighted value as a custom molar mass in density mode; the molar-mass calculator next door computes component M values from chemical formulas.

What are "standard conditions", and why does my reference say 24.5 L/mol?

Two conventions coexist. The classic STP (0 °C, 1 atm = 101.325 kPa) gives the 22.414 L/mol molar volume this tool's worked example reproduces. IUPAC's current standard-state pressure is 100 kPa, which at 0 °C gives 22.711 L/mol, and "ambient" tables at 25 °C and 1 atm give 24.465 L/mol. All follow from the same V = RT/P — enter the stated pressure and temperature and the tool matches whichever convention your reference uses.