Ideal Gas Law Calculator (PV = nRT)
Solve PV = nRT for pressure, volume, moles or temperature in any units (atm, kPa, bar, mmHg, psi; L, mL, m³; K, °C, °F). Includes a Boyle's-law plot.
PV = nRT — pick what to solve for
Boyle's law: pressure against volume
At your n and T. The dot is your gas.
Show the Larzscript program that just ran
Run a calculation to see the exact program.
This is the real program the page sent to the Larzscript interpreter (compiled to WebAssembly) in your browser. The library it imports is the same code the automated tests check.
The law and its special cases
Holding n and T fixed gives Boyle's law (P₁V₁ = P₂V₂); holding n and P fixed gives Charles's law (V/T constant); holding n and V fixed gives Gay-Lussac's law (P/T constant); and combining them gives P₁V₁/T₁ = P₂V₂/T₂. Avogadro's principle — equal volumes of gases at the same T and P hold equal numbers of molecules — is the n in the equation.
Worked examples, computed above
- One mole at 0 °C and 1 atm occupies 22.414 L; at 25 °C it is 24.465 L.
- 2 mol in a 10 L tank at 300 K exerts 4.923 atm.
- A 22.414 L container at 1 atm and 273.15 K contains 1 mol.
- Dry air at 1 atm and 0 °C has density 1.292 g/L, and 1.184 g/L at 25 °C.
What is verified
Six ideal-gas problems, solved for each of the four unknowns, are compared with 60-digit decimal arithmetic on the exact inputs; R is checked against the SI-defined value; molar volumes at 0 °C (22.414 L) and 25 °C (24.465 L) are asserted; and the combined-gas law and Graham's law are checked with closed forms. Mutation tests confirm the checks fail if T and P are swapped.
Limits: ideal gas only. For accurate work above about 10 atm or near a boiling point, use a real-gas equation of state.
Frequently asked questions
What is the ideal gas law?
PV = nRT: pressure × volume = amount of gas (moles) × the gas constant × absolute temperature. It is accurate for gases at low pressure and high temperature, where molecules are far apart and interact little.
What value of R should I use?
It depends on the units. This calculator uses R = 0.082057366 L·atm/(mol·K), derived from the exact SI value 8.314462618… J/(mol·K), converts every unit you choose, and reports the result in the same units.
What is the volume of one mole of gas at STP?
22.414 L at 0 °C (273.15 K) and 1 atm; 24.465 L at 25 °C. The IUPAC standard (1 bar, 0 °C) gives 22.711 L. The number depends on the definition of 'standard', so state which one you use.
Why must temperature be in kelvin?
Because gas volume is proportional to absolute temperature: doubling 20 °C to 40 °C does not double the volume, but doubling 293 K to 586 K does. The calculator converts °C and °F for you.
How do I find the number of moles of a gas?
n = PV/RT. A 22.414 L container at 1 atm and 0 °C holds 1 mol. Multiply by the molar mass (see the molar mass calculator) to get grams.
When does the ideal gas law fail?
At high pressure (above roughly 10 atm), at low temperature near condensation, and for strongly interacting gases such as steam or ammonia. Real gases need the van der Waals or another equation of state; the ideal law error for nitrogen at 1 atm and 25 °C is about 0.1%.
Every number on this page is computed by the open-source larzscript-chem library (chemistry, physconst, physmath), written in Larzscript, and checked against independent references in its test suite. How it is verified →