Chemical Engineering · Thermodynamics
Ideal gas law calculator icon showing a gas cylinder with pressure, volume and temperature labels

Ideal gas law calculator

This ideal gas law calculator solves PV = nRT for pressure, volume, amount of gas or temperature, and works out gas density and molar volume from the molar mass.

Temperature must be absolute in PV = nRT. You can type it in °C or °F; the calculator converts it to kelvin first and stops with an error at or below 0 K.

Ideal gas law calculator: solve PV = nRT

Pick the unknown, then enter the other three quantities. R = 8.314462618 J/(mol·K).
Use absolute pressure: gauge pressure + atmospheric pressure.

Gas density and molar volume with the ideal gas law calculator

Enter pressure, temperature and molar mass. Add a mass to get the number of moles and the volume it occupies.
Air 28.97, N₂ 28.01, O₂ 32.00, CO₂ 44.01, CH₄ 16.04, H₂ 2.016 g/mol.

How to use the ideal gas law calculator

The first panel solves the ideal gas equation itself. Choose the unknown (pressure, volume, amount of gas or temperature), type the other three values in any units, and the ideal gas law calculator returns the answer in several units together with the molar volume and the number of molecules. The second panel answers the most common practical questions: what is the density of this gas, how much volume does one mole occupy, and how many moles (and cubic meters) are in a given mass? For a fixed amount of gas that moves between two states, such as a cylinder that is heated or a gas that is compressed, use the combined gas law calculator (P₁V₁/T₁ = P₂V₂/T₂) instead. Open “Show the working” to see each substitution, in SI units, ready for a homework solution.

The ideal gas law: PV = nRT

The ideal gas law combines Boyle’s law (PV constant at fixed T), Charles’s law (V proportional to T at fixed P) and Avogadro’s law (V proportional to n) into a single equation of state. It treats molecules as points that do not attract or repel each other, which is a good model for most gases at low pressure and well above their boiling point. NASA Glenn Research Center’s page on the equation of state shows how the same relation is written per unit mass for air in aerodynamics.

P · V = n · R · T
ρ = P · M / (R · T) and V/n = R · T / P

Here P is the absolute pressure (Pa), V the volume (m³), n the amount of gas (mol), T the absolute temperature (K), M the molar mass (kg/mol) and R the universal gas constant, 8.314462618 J/(mol·K), which has been an exact value since the 2019 SI redefinition. The ideal gas law calculator converts every input to these SI units before it solves, so you can mix psi, liters and °F freely.

Values of the gas constant R for the ideal gas law calculator and hand work

Most errors in hand calculations come from using an R that does not match the units of P and V. If you work without an ideal gas law calculator, pick the row that matches your data:

Value of RUnitsTypical use
8.314462618J/(mol·K) = Pa·m³/(mol·K)SI calculations, thermodynamics
8.3145L·kPa/(mol·K)Liters with pressures in kPa (same number as in J/(mol·K))
0.082057L·atm/(mol·K)General chemistry, pressures in atm
0.083145L·bar/(mol·K)Pressures in bar
62.364L·mmHg/(mol·K) = L·torr/(mol·K)Vacuum work and vapor pressure data in mmHg (torr)
1.9872cal/(mol·K)Older thermochemistry tables
10.7316ft³·psi/(lbmol·°R)US customary process calculations
1545.35ft·lbf/(lbmol·°R)Compressor and gas-flow work in US units
1.9859BTU/(lbmol·°R)US customary energy balances

Worked example with the ideal gas law calculator

Pressure in a vessel. Two moles of nitrogen are held in a 50 L vessel at 25 °C. Convert the temperature to kelvin, T = 25 + 273.15 = 298.15 K, and the volume to cubic meters, V = 0.050 m³. Then P = nRT/V = 2 × 8.314462618 × 298.15 / 0.050 = 99,158 Pa ≈ 99.16 kPa, or 0.9786 atm. The molar volume is 50 / 2 = 25 L/mol. Select “Pressure, P” in the ideal gas law calculator with the default values and you get the same numbers.

Density of air. The second panel uses M = 28.97 g/mol, P = 101.325 kPa and T = 25 °C: ρ = 101,325 × 0.02897 / (8.314462618 × 298.15) = 1.184 kg/m³, and V/n = 24.465 L/mol. One kilogram of air is 1000 / 28.97 = 34.52 mol and occupies 34.52 × 0.024465 = 0.8445 m³ at these conditions.

All rows are the same constant, 8.314462618 J/(mol·K), divided by the unit conversions: 101.325 J per L·atm, 0.133322 J per L·mmHg, and for the US row 1 lbmol = 453.59237 mol, 1 °R = 1/1.8 K, 1 psi = 6,894.757 Pa and 1 ft³ = 0.0283168 m³, which gives 10.7316 ft³·psi/(lbmol·°R).

Worked example in US units: nitrogen in a storage tank

Problem. A 10 ft³ tank holds nitrogen at 150 psig and 80 °F. How many pound-moles and pounds of N₂ does it contain, and how many standard cubic feet (60 °F, 14.696 psia) is that?

Step 1, absolute units. P = 150 + 14.696 = 164.696 psia; T = 80 + 459.67 = 539.67 °R. Step 2, choose the matching R. With ft³, psia and °R use R = 10.7316 ft³·psi/(lbmol·°R). Step 3, solve for n. n = PV/(RT) = 164.696 × 10 / (10.7316 × 539.67) = 0.2844 lbmol. Step 4, mass. m = n·M = 0.2844 × 28.014 = 7.97 lb. Step 5, standard volume. One lbmol of ideal gas at 60 °F and 14.696 psia occupies 10.7316 × 519.67/14.696 = 379.5 ft³, so the tank holds 0.2844 × 379.5 = 107.9 scf. In the ideal gas law calculator choose “Amount of gas, n”, enter 164.696 psi, 10 ft³ and 80 °F, and read 0.2844 lbmol in the result. At 150 psig nitrogen is still within about 1 % of ideal at room temperature, so the answer needs no Z correction.

Density of a gas from the ideal gas law

Writing n = m/M in PV = nRT and dividing by V gives the ideal gas density, the most used rearrangement in process work (gas line sizing, fan and blower calculations, stack and flare loads):

ρ = m/V = P · M / (R · T)

Example. Carbon dioxide at 20 °C and 1 atm: ρ = 101,325 Pa × 0.04401 kg/mol / (8.314462618 J/(mol·K) × 293.15 K) = 1.830 kg/m³. Because ρ is proportional to M at fixed P and T, a gas is denser than air when its molar mass is above 28.97 g/mol, which is why CO₂ collects in pits and basements while methane rises. The table below was computed the same way; the second panel of the ideal gas law calculator gives the value at any other pressure and temperature.

GasMolar mass M (g/mol)Ideal density at 20 °C, 1 atm (kg/m³)Same in lb/ft³Relative to air
Air (dry)28.971.2040.075181.000
Nitrogen, N₂28.0141.1650.072700.967
Oxygen, O₂31.9991.3300.083041.105
Carbon dioxide, CO₂44.0101.8300.114211.519
Methane, CH₄16.0430.66690.041630.554

Measured densities of air, N₂, O₂ and CH₄ under these conditions differ from the ideal values by less than about 0.2 %; CO₂, the most easily condensed gas in the table, is about half a percent denser than the ideal value because its compressibility factor is slightly below 1.

STP, NTP and the molar volume of an ideal gas

“Standard conditions” are not universal, and the molar volume you quote depends on which definition you use. IUPAC defines standard temperature and pressure as 0 °C and 10⁵ Pa (IUPAC Gold Book: standard conditions for gases); many older textbooks and the gas industry still use 1 atm. Set n = 1 mol and solve for V, and the ideal gas law calculator gives the molar volume V/n = RT/P for any of them: 22.711 L/mol at 0 °C and 100 kPa, or 22.414 L/mol at 0 °C and 1 atm. The full table of reference conditions (IUPAC STP, older STP, NTP, SATP and the US standard cubic foot), together with a panel that corrects a measured gas volume to standard conditions, is on the combined gas law calculator page. When a supplier quotes a flow in Nm³/h or SCFM, always check which reference temperature and pressure they mean; the difference between 0 °C and 20 °C alone is 7%.

Reference conditionTemperaturePressureMolar volume of an ideal gas
STP (IUPAC, since 1982)0 °C (273.15 K)1 bar (100 kPa)22.711 L/mol
STP (older definition)0 °C (273.15 K)1 atm (101.325 kPa)22.414 L/mol
NTP20 °C (293.15 K)1 atm (101.325 kPa)24.055 L/mol
SATP25 °C (298.15 K)1 bar (100 kPa)24.790 L/mol
Room conditions often used in chemistry25 °C (298.15 K)1 atm (101.325 kPa)24.465 L/mol
US gas industry standard60 °F (519.67 °R)14.696 psia379.5 ft³/lbmol

Every value in this table is V/n = RT/P with R = 8.314462618 J/(mol·K); the ideal gas law calculator reproduces them if you enter n = 1 mol (or 1 lbmol) and solve for V.

When an ideal gas law calculator is not enough: the compressibility factor Z

Real molecules occupy volume and attract each other. Both effects grow as the gas gets denser, so the ideal gas law loses accuracy at high pressure and at low temperature, especially near the saturation curve. The correction is the compressibility factor Z = PV/(nRT): Z = 1 for an ideal gas, Z below 1 when attraction dominates (for example natural gas at 50–150 bar, where Z is often 0.8–0.9), and Z above 1 at very high pressure where molecular size dominates. Z is usually read from a generalized chart as a function of reduced temperature T/Tc and reduced pressure P/Pc, or calculated with an equation of state such as van der Waals, Redlich-Kwong or Peng-Robinson. The compressibility factor calculator finds Z from measured PVT data, from the Pitzer correlation or from the Peng-Robinson equation, so you can correct the ideal gas law calculator result with PV = ZnRT.

As a rule of thumb, an ideal gas law calculator is accurate to within about 1–2% for air, nitrogen, oxygen, hydrogen and helium up to roughly 10 bar near room temperature. Steam, CO₂, ammonia and hydrocarbons heavier than methane deviate sooner, because they are closer to condensing. Never use PV = nRT for liquids or for vapor at its saturation point.

Common mistakes with PV = nRT and the ideal gas law calculator

Using °C or °F instead of kelvin or rankine. The law needs absolute temperature; 0 °C is not “zero temperature”. Using gauge pressure. A tire at 220 kPa gauge is at about 321 kPa absolute. Mismatched R. 0.08206 only works with liters and atmospheres. Molar mass in g/mol in an SI density formula. Divide by 1000 to get kg/mol, or the density comes out 1000 times too large. Mixing up standard conditions. 22.4 L/mol is for 0 °C and 1 atm, not for room temperature. The ideal gas law calculator handles all of these conversions automatically, but you still need to enter absolute pressure.

Related calculators

Gas densities from the ideal gas law calculator feed directly into the Reynolds Number Calculator and the Pressure Drop Calculator for gas lines. For thermal properties see the Enthalpy Calculator, and convert temperature scales with the Temperature Converter.

Frequently asked questions

What is the ideal gas law formula?

PV = nRT, where P is absolute pressure, V volume, n the amount of gas in moles, T absolute temperature and R = 8.314462618 J/(mol·K). Rearranged, it gives P = nRT/V, V = nRT/P, n = PV/(RT) and T = PV/(nR).

Why must temperature be in kelvin?

Because volume and pressure are proportional to absolute temperature. Doubling the temperature from 10 °C to 20 °C does not double the volume; going from 283.15 K to 566.3 K does. The ideal gas law calculator converts °C and °F to kelvin before solving.

What is the molar volume of a gas at STP?

At the IUPAC standard of 0 °C and 100 kPa it is 22.711 L/mol; at 0 °C and 1 atm it is 22.414 L/mol; at 25 °C and 1 atm it is 24.465 L/mol.

What is R in L·atm?

R = 0.082057 L·atm/(mol·K) (0.08205736 to more digits). Use it only when P is in atmospheres and V in liters; with kPa and liters use 8.3145 L·kPa/(mol·K), with mmHg use 62.364 L·mmHg/(mol·K). The ideal gas law calculator converts units for you, so it always uses the SI value internally.

When does the ideal gas law fail?

When the gas is dense: at high pressure (roughly above 10 bar for light gases, sooner for CO₂, steam, ammonia and hydrocarbons), at low temperature, and close to the saturation curve where the gas is about to condense. There the compressibility factor Z = PV/(nRT) moves away from 1. Use PV = ZnRT with Z from a generalized chart or an equation of state; the compressibility factor calculator on this site computes Z.

How do I find the density of a gas?

Use ρ = P·M/(R·T) with M in kg/mol. Air at 25 °C and 1 atm has ρ ≈ 1.184 kg/m³. The second panel of the ideal gas law calculator does this for any gas.

Is this ideal gas law calculator free?

Yes. It runs in your browser, needs no sign-up and does not store or send the values you enter.