Ideal Gas Law Calculator

Last Updated: August 6, 2026

Calculate the pressure, volume, moles, or temperature of a gas using the ideal gas law PV = nRT, with unit conversion, mass and density outputs, and a real-gas accuracy check.

Enter the three remaining values. The calculator rearranges PV = nRT and solves for the one you picked.

+ Gas identity and real-gas check (optional)

Ideal Gas Law Formula

P*V = n*R*T

Rearranged for each variable the calculator can solve:

P = n*R*T / V V = n*R*T / P n = P*V / (R*T) T = P*V / (n*R)
  • P = absolute pressure of the gas (Pa in SI)
  • V = volume the gas occupies (m3 in SI)
  • n = amount of gas (mol)
  • R = universal gas constant, 8.31446 J/(mol·K)
  • T = absolute temperature (K)

The value of R changes with the units you feed it: 8.31446 J/(mol·K) for pascals and cubic meters, 0.082057 L·atm/(mol·K) for liters and atmospheres, and 0.083145 L·bar/(mol·K) for liters and bar. The calculator sidesteps that problem by converting every input to pascals, cubic meters, moles and kelvin, solving with the SI value of R, then converting the answer back into the units you want to read.

What each part of the calculator does:

  • The solve-for selector picks which of the four rearrangements above is used and hides the field for that variable, so only the three knowns stay on screen.
  • Temperature is always converted to kelvin before the math. Entering 25 °C gives 298.15 K, not 25.
  • The amount of gas can be entered as moles or as a mass. Mass is divided by the molar mass to get n, which is what the equation actually needs.
  • Selecting a gas adds molar mass driven outputs: total mass, density in g/L, and molar volume in L/mol.
  • The real-gas check solves the van der Waals equation, (P + a/Vm2)(Vm – b) = R*T, at the same temperature and molar volume, then reports the compressibility factor Z = Preal/Pideal so you can see how much error the ideal assumption is costing you.

Where PV = nRT Stops Being Accurate

The ideal gas law assumes molecules have no volume and no attraction for each other. Both assumptions fail as pressure rises and as temperature drops toward the boiling point of the gas. The table below gives the compressibility factor Z at 1 atm and 25 °C for common gases, along with the pressure at 25 °C where the van der Waals model puts the ideal gas error past 5 percent. Below that pressure, PV = nRT is good enough for most work.

Gas Molar mass (g/mol) Critical temp (K) Z at 1 atm, 25 °C Error passes 5% near
Helium4.005.21.000955 atm
Hydrogen2.0233.21.000769 atm
Nitrogen28.01126.20.9993240 atm
Oxygen32.00154.60.999055 atm
Argon39.95150.90.999159 atm
Methane16.04190.60.998025 atm
Carbon dioxide44.01304.10.995712 atm
Ammonia17.03405.50.99459 atm (it liquefies near 9.9 atm)
Water vapor18.02647.1condenses at 0.031 atmZ is 0.995 for steam at 1 atm, 100 °C

Temperature matters as much as pressure. Carbon dioxide at 10 atm has Z near 0.879 at 200 K, 0.945 at 273 K, 0.956 at 298 K and 0.989 at 500 K, so the same pressure that ruins an answer in a cold trap is harmless in a furnace. As a rule of thumb, a gas behaves ideally when its temperature is well above its critical temperature and its pressure is well below its critical pressure.

Use this table to read the compressibility factor the calculator reports.

Z value What it means What to do
0.99 to 1.01Attractions and molecular volume nearly cancelUse the ideal gas answer as is
0.95 to 0.99Attractions dominate slightly, real volume is smaller than predictedAcceptable for coursework and rough engineering, note the 1 to 5 percent error
Below 0.95Strong intermolecular attraction, gas is near condensationSwitch to van der Waals, Peng-Robinson, or a compressibility chart
Above 1.05Molecular volume dominates, gas resists compressionCommon for helium and hydrogen at high pressure, correct with Z

Example Problems

Example 1: find the pressure. You have 1.00 mol of air in a 22.4 L vessel at 273.15 K.

  1. Convert the volume to SI: 22.4 L = 0.0224 m3.
  2. Multiply n, R and T: 1.00 × 8.31446 × 273.15 = 2271.1 J.
  3. Divide by volume: P = 2271.1 / 0.0224 = 101,388 Pa.
  4. Convert: 101,388 Pa = 1.0006 atm. The molar volume is 22.4 L/mol and the density of air here is 1.29 g/L. The real-gas check returns Z = 0.999, so the ideal answer stands.

Example 2: find the amount of gas. A 10.0 L cylinder of air sits at 2.00 atm and 300 K.

  1. Convert: 2.00 atm = 202,650 Pa and 10.0 L = 0.0100 m3.
  2. Multiply P by V: 202,650 × 0.0100 = 2026.5 J.
  3. Multiply R by T: 8.31446 × 300 = 2494.3 J/mol.
  4. Divide: n = 2026.5 / 2494.3 = 0.8124 mol. At a molar mass of 28.96 g/mol that is 23.5 g of air, or 4.89 × 1023 molecules.

FAQ

Do I have to convert temperature to kelvin?

Yes. The ideal gas law is built on absolute temperature, where zero means zero molecular kinetic energy. Using 25 instead of 298.15 K makes the answer wrong by a factor of about 12, and using a negative Celsius value produces a negative pressure or volume, which is physically meaningless. Rankine works too if you pair it with an R value in Rankine. The calculator accepts Celsius, Fahrenheit and Rankine and converts them for you.

Which value of R should I use?

Match R to your units. Use 8.31446 J/(mol·K) with pascals and cubic meters, 0.082057 L·atm/(mol·K) with liters and atmospheres, 0.083145 L·bar/(mol·K) with liters and bar, and 62.364 L·torr/(mol·K) with liters and torr. Mixing an R value with the wrong pressure unit is the single most common error on ideal gas problems, and it usually shows up as an answer that is off by a factor of 101,325 or 760.

When should I stop using the ideal gas law?

Stop when the compressibility factor drifts more than about 5 percent from 1. In practice that means high pressure, low temperature, or a polar gas such as ammonia or water vapor. Carbon dioxide crosses that line near 12 atm at room temperature, methane near 25 atm, and nitrogen not until roughly 240 atm. Above those pressures, switch to the van der Waals equation or a cubic equation of state such as Peng-Robinson, or apply a compressibility factor from a generalized chart: PV = ZnRT.