Chemistry & Chemical Engineering Gas Laws & Kinetic Theory Ideal gas law, PV = nRT (CODATA 2018 gas constant)

Ideal Gas Law Calculator (PV = nRT)

The ideal gas law ties the four state variables of a gas together in one equation: PV = nRT. Give this calculator any three of pressure, volume, amount and temperature and it returns the fourth, plus the molar volume, the mass and the density if you supply a molar mass. Pressure accepts atm, kPa, bar, psi, mmHg or Pa; volume accepts litres, millilitres, cubic metres or cubic feet; temperature accepts any of the four common scales and is converted to kelvin before the arithmetic, which is where most hand calculations go wrong.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Solve forChoose the unknown; fill in the other three.Volume V
Temperature scaleThe scale you type the temperature in and the scale a solved temperature is reported in.Celsius (°C)
Pressure PAbsolute pressure, not gauge pressure — add local atmospheric pressure to a gauge reading first.1 atm
Volume VThe volume the gas occupies — the free internal volume of the vessel, not its outside dimensions.24.4654 L
Amount of gas nMoles of gas present; divide a mass in grams by the molar mass if that is what you have.1 mol
Temperature TGas temperature in the scale selected above; it is converted to kelvin before use.25
Molar massMolar mass of the gas; 28.96 g/mol is dry air, 2.016 is H₂, 44.01 is CO₂. Leave at 0 to skip mass and density.28.96 g/mol

It returns

  • Solved value — Pressure in atm, volume in L, amount in mol, or temperature in the scale you selected — whichever you asked for.
  • Pressure
  • Volume
  • Amount of gas
  • Temperature
  • Molar volume V/n — 22.414 L/mol at 0 °C and 1 atm; 24.465 L/mol at 25 °C and 1 atm.
  • Mass of gas
  • Gas density

The formula

PV=nRT
ρ=PMRT
n=mM
P1V1n1T1=P2V2n2T2

In plain text: P · V = n · R · T (T in kelvin)

  • PAbsolute pressure of the gas (atm)
  • VVolume the gas occupies (L)
  • nAmount of gas (mol)
  • RUniversal gas constant, 0.08205737 L·atm/(mol·K) = 8.314463 J/(mol·K) (L·atm/(mol·K))
  • TAbsolute temperature (K)

Exact only for a hypothetical gas of point particles with no intermolecular forces. Real gases follow it closely at low pressure and well above their boiling points; the correction factor Z in PV = ZnRT measures the departure.

Updated Category Gas Laws & Kinetic Theory Verified against published test cases Reading time 11 min

What the ideal gas law states

The ideal gas law fixes the relationship between the four quantities that fully describe a gas sample: how hard it pushes (pressure), how much room it fills (volume), how much of it there is (moles), and how hot it is (absolute temperature). Fix any three and the fourth is determined. That is a remarkable claim — it says the chemical identity of the gas does not matter. A mole of helium and a mole of sulfur hexafluoride occupy the same volume at the same pressure and temperature, despite a 36-fold difference in molar mass.

The equation is PV = nRT, where R is the universal gas constant. R exists purely to reconcile the units: it is the constant of proportionality between PV, which has the dimensions of energy, and nT. Its numerical value therefore changes with the unit system, and choosing the wrong version of R is the second most common error in gas calculations after forgetting kelvin.

The law is a consolidation of the three simple gas laws discovered separately in the seventeenth to nineteenth centuries. Boyle's law (PV constant at fixed T and n), Charles's law (V proportional to T at fixed P and n) and Avogadro's law (V proportional to n at fixed P and T) each capture one slice; multiply them together and PV = nRT falls out.

You reach for it whenever you need to convert between a gas measured as a volume and a gas measured as an amount. Filling a reaction vessel to a target pressure, working out how many grams of propane a cylinder holds, converting a gas-chromatography injection volume to moles, or sizing a vent for a decomposition that releases gas all reduce to one application of this equation.

Reading each variable, and choosing the right R

P is absolute pressure. Not gauge pressure. A tyre gauge reading 30 psi on a gauge is 30 psig, which is about 44.7 psia — the gauge subtracts atmospheric pressure. Every pressure sensor labelled “g” needs local atmospheric pressure added before it enters PV = nRT. Use absolute units: atm, bar, kPa absolute, psia, or mmHg.

V is the free internal volume. If the vessel contains liquid or packing, subtract it. A 500 mL round-bottom flask holding 100 mL of solution has 400 mL of headspace for the gas.

n is the amount in moles. If you have a mass, divide by molar mass: n = m/M. This calculator does the reverse for you — supply a molar mass and it reports both the mass and the density.

T is absolute temperature. Kelvin or Rankine only. Every one of the four rearrangements either multiplies or divides by T, so a Celsius value simply produces a wrong answer rather than a nearly-right one. At room temperature, using 25 instead of 298.15 is a twelve-fold error.

R depends on the units you chose. The physical constant is fixed — the SI value is exactly 8.314462618 J/(mol·K) since the 2019 redefinition of the mole and the kelvin — but its numerical expression is not. This calculator works internally in litre-atmospheres, using R = 0.08205737 L·atm/(mol·K), and converts your inputs into atm and litres first. If you are checking a hand calculation, use the table below to pick the matching R.

A useful rearrangement worth memorising is the density form, ρ = PM/(RT). It says gas density rises linearly with pressure and with molar mass and falls inversely with absolute temperature — which is why hot air rises, why carbon dioxide pools in a pit, and why a helium balloon lifts.

Worked example: how many moles are in a 5.00 L cylinder at 2.00 atm and 27 °C?

A 5.00 L stainless cylinder is filled with nitrogen to an absolute pressure of 2.00 atm at 27 °C. How many moles does it hold, and what does that gas weigh?

  1. Convert the temperature. T = 27 + 273.15 = 300.15 K. For a clean hand check, use 300 K.
  2. Pick R to match the units. Pressure is in atm and volume in litres, so R = 0.0820574 L·atm/(mol·K).
  3. Form the denominator. R × T = 0.0820574 × 300 = 24.6172 L·atm/mol.
  4. Form the numerator. P × V = 2.00 atm × 5.00 L = 10.00 L·atm.
  5. Divide. n = 10.00 ÷ 24.6172 = 0.40622 mol.
  6. Convert to mass. Nitrogen is N₂, M = 28.014 g/mol, so m = 0.40622 × 28.014 = 11.38 g.
  7. Density check. ρ = m ÷ V = 11.38 ÷ 5.00 = 2.276 g/L. Cross-check with ρ = PM/(RT) = (2.00 × 28.014) ÷ 24.6172 = 2.276 g/L. The two routes agree, which confirms the arithmetic.

Now change one thing to see the sensitivity. Warm the same cylinder to 127 °C (400.15 K) without venting it. The volume is fixed and n is fixed, so the pressure rises in proportion to absolute temperature: P₂ = 2.00 × 400.15 ÷ 300.15 = 2.666 atm. That is a 33% pressure rise for a 100 °C warming, which is why gas cylinders carry a maximum storage temperature.

The gas constant R in common unit systems

All rows are the same physical constant, R = 8.314462618 J/(mol·K) (CODATA 2018, exact since the 2019 SI redefinition), expressed in different units. Use the row whose units match your P and V.
Value of RUnitsUse when P is in……and V is in
0.08205737L·atm/(mol·K)atmlitres
8.314463J/(mol·K)Pa
8.314463L·kPa/(mol·K)kPalitres
0.08314463L·bar/(mol·K)barlitres
62.36360L·mmHg/(mol·K)mmHg (torr)litres
1.987204cal/(mol·K)energy form
10.73159ft³·psi/(lbmol·°R)psiacubic feet

The calorie row is the energy form used in older thermodynamic tables; it is not paired with a pressure and volume unit.

Molar volume under the standard states you may be asked for

Molar volume V/n = RT/P. Every one of these is called “standard” by someone, so always state which you used.
Reference stateTemperaturePressureMolar volume
IUPAC STP (since 1982)0 °C (273.15 K)100 kPa (1 bar)22.711 L/mol
Former IUPAC STP0 °C (273.15 K)101.325 kPa (1 atm)22.414 L/mol
NIST standard conditions20 °C (293.15 K)101.325 kPa (1 atm)24.055 L/mol
SATP / ambient25 °C (298.15 K)100 kPa (1 bar)24.790 L/mol
Room conditions, 1 atm25 °C (298.15 K)101.325 kPa (1 atm)24.465 L/mol

The extremes here are 22.414 and 24.790 L/mol, a spread of 10.6%. A gas volume quoted without its reference state cannot be converted to moles.

How far you can trust the answer

Ask two questions: is the pressure low, and is the temperature well above the boiling point? If both answers are yes, the ideal gas law is accurate to better than one percent and you can stop worrying.

The formal measure of the departure is the compressibility factor Z = PV/(nRT), which equals exactly 1 for an ideal gas. For nitrogen, oxygen and air near room temperature, Z stays within about 1% of unity up to roughly 10 atm; by 100 atm the error is tens of percent. Gases that condense easily — ammonia, carbon dioxide, propane, water vapour — deviate sooner, because intermolecular attraction pulls the molecules together and the real volume falls below the ideal prediction. Above the critical temperature and at high pressure the effect reverses: the finite size of the molecules dominates and the real volume exceeds the ideal one.

Two practical checks catch most mistakes. First, look at the molar volume this calculator reports. Anywhere near room conditions it should land between about 20 and 30 L/mol. A value of 2 L/mol means a unit slipped by a factor of ten somewhere; a value of 0.02 L/mol is a liquid density and the model does not apply. Second, sanity-check the density against a known gas: air is about 1.2 g/L at room conditions, hydrogen about 0.082 g/L, carbon dioxide about 1.8 g/L.

When the answer matters and the pressure is high, move to a real-gas equation of state — van der Waals for teaching, Peng-Robinson or Soave-Redlich-Kwong for process work — or look up a tabulated Z. For gas mixtures, apply Dalton's law of partial pressures: each component obeys PV = nRT with its own partial pressure, and the total pressure is the sum.

Errors that make PV = nRT give the wrong answer

  • Gauge pressure instead of absolute. Add local atmospheric pressure — roughly 14.7 psi or 101 kPa at sea level — to any gauge reading before it goes into the equation.
  • Celsius instead of kelvin. Every rearrangement uses T directly, so a Celsius value is not a small error; at room temperature it is off by a factor of twelve.
  • An R that does not match the units. Using 8.314 with pressure in atm and volume in litres throws the answer out by the factor 101.325 — too large if you solved for P or V, too small if you solved for n or T, because R sits on opposite sides of those rearrangements. Match R to your units or convert first.
  • Counting the vessel's total volume instead of the headspace. Liquid, catalyst and packing all displace gas.
  • Applying it near condensation or above about 10 atm. The deviation is systematic, not random, and it always makes the real volume differ from the ideal one in a predictable direction for a given gas and state.
  • Treating a gas mixture as a single species. Use partial pressures for each component, or an average molar mass for density work — 28.96 g/mol for dry air is exactly such an average.

Where to go beyond PV = nRT

If your problem holds one variable fixed, a two-state form is faster and needs no value of R at all. With n and T fixed you have Boyle's law, P₁V₁ = P₂V₂. With n and P fixed you have Charles's law, V₁/T₁ = V₂/T₂. With n and V fixed you have Gay-Lussac's law, P₁/T₁ = P₂/T₂. All three drop out of PV/(nT) being constant.

For gases participating in reactions, PV = nRT is the bridge between the measured volume and the stoichiometry: convert to moles, run the mole ratio, convert back. When the gas is a reactant or product at equilibrium, the partial pressures feed straight into the equilibrium constant as Kp, and the reaction quotient tells you which way the system will move. When the gas is dissolving rather than filling a container, Henry's law replaces this equation, and the colligative behaviour of the resulting solution is handled by osmotic pressure — which, notably, has the identical form Π = (n/V)RT.

The energy side of a gas process is separate arithmetic. Heating a gas at constant pressure does work on the surroundings equal to PΔV, and the heat required follows from its heat capacity; use the calorimetry calculator for the q = mcΔT part and the Gibbs free energy calculator for whether a gas-phase process runs at all.

Frequently asked questions

What value of R should I use?

Use the one whose units match your pressure and volume. With atm and litres, R = 0.0820574 L·atm/(mol·K); with pascals and cubic metres, R = 8.314463 J/(mol·K); with kPa and litres it is also 8.314463; with bar and litres it is 0.0831446. All are the same constant expressed differently. This calculator converts your inputs to atm and litres internally and uses 0.08205737.

Do I use gauge or absolute pressure in PV = nRT?

Absolute, always. A gauge reads the amount by which pressure exceeds the surrounding atmosphere, so a gauge reading of zero corresponds to about 1 atm absolute. Add local atmospheric pressure — 101.3 kPa or 14.7 psi at sea level, less at altitude — to any gauge value before entering it. Pressures marked psia, bara or “absolute” need no adjustment.

What is the molar volume of a gas at STP?

22.414 L/mol at 0 °C and 1 atm, or 22.711 L/mol at 0 °C and 100 kPa, which is the definition IUPAC has used since 1982. Textbooks differ on which they mean by “STP”, so check the reference state before you use either. At the more practical 25 °C and 1 atm the molar volume is 24.465 L/mol.

How do I find gas density from the ideal gas law?

Use ρ = PM/(RT), where M is the molar mass in g/mol. It comes straight from PV = nRT by substituting n = m/M and rearranging for m/V. Enter a molar mass above and the calculator reports both mass and density. Dry air has an average M of 28.96 g/mol, which gives 1.292 g/L at 0 °C and 1 atm.

When does the ideal gas law stop working?

At high pressure and near the condensation temperature. For common gases at room temperature the error is under about 1% below 10 atm and grows quickly above that. Gases with strong intermolecular attraction — ammonia, water vapour, carbon dioxide, propane — deviate at lower pressures than nitrogen or helium. Use the compressibility factor Z in PV = ZnRT, or a real-gas equation of state, when accuracy matters in those regimes.

Can I use the ideal gas law for a mixture of gases?

Yes, in two ways. Applied to the whole mixture with the total pressure, it gives the total number of moles present. Applied to one component with its partial pressure, it gives that component's moles — this is Dalton's law. For density work on a mixture, use the mole-fraction-weighted average molar mass, which is where the figure of 28.96 g/mol for dry air comes from.

Why does my answer change so much when I switch temperature units?

Because only kelvin and Rankine are absolute scales. Volume, pressure and moles all scale with T measured from absolute zero, so 25 °C must become 298.15 K before it is used. If you enter 25 as though it were kelvin, the calculation runs at a temperature just above absolute zero and every result is roughly twelve times off. Selecting the correct scale above prevents this.

How do I get moles from a mass of gas?

Divide the mass in grams by the molar mass in g/mol: n = m ÷ M. For 11.38 g of nitrogen, M = 28.014 g/mol, so n = 0.4062 mol. Working the other way, enter the molar mass in the optional field above and the calculator reports the mass corresponding to the moles it solved for.

Does the identity of the gas matter?

Not for the P, V, n and T relationship — that is what makes the law useful. One mole of any ideal gas occupies the same volume at the same pressure and temperature, regardless of molar mass. Identity matters only for the derived quantities: mass and density scale directly with molar mass, and how far a real gas departs from ideality depends on its molecular size and polarity.

References