Ideal Gas Law Calculator
The ideal gas law is PV = nRT, with R equal to 8.314462618 J per mole per kelvin. One mole of gas at 273.15 K and 101.325 kPa fills 22.414 liters, which is the molar volume used to check every other answer on this page.
Pick the quantity you want to solve for, fill the other three in any unit, and the calculator works inside SI units so the gas constant never has to be converted. Temperature is always treated as absolute.
| Result | |
| Pressure, absolute | |
| Volume | |
| Amount of gas | |
| Temperature | |
| Molar volume at these conditions | |
| Density from molar mass | |
| Check: n = PV / RT |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter three of pressure, volume, amount and temperature and this page solves the fourth with PV = nRT, converting among atm, kPa, psi, liters, cubic meters, moles, grams and kelvin.
Key takeaways
- PV = nRT needs absolute temperature, so 25 °C enters the equation as 298.15 K
- One mole at 273.15 K and 101.325 kPa occupies 22.414 L
- A 12 liter tank at 200 atm and 20 °C holds 99.77 mol, about 2.89 kg of air
- Density comes from the same law as PM / RT, giving 1.184 g/L for air at 25 °C
- Above roughly 10 atm and near a gas boiling point, real gases drift from the ideal answer
On this page
The ideal gas law in one line
PV = nRT ties four quantities together: pressure in pascals, volume in cubic meters, amount in moles, and temperature in kelvin. R is the molar gas constant, and its value depends on nothing except the units you feed it.
The 2022 CODATA adjustment published by the National Institute of Standards and Technology fixes the constant at 8.314462618 J mol^-1 K^-1 exactly, with no uncertainty, because it is now defined through the Boltzmann constant and the Avogadro constant. That exactness is why a calculator can quote twelve digits without hedging.
The law is a model, not a law of nature in the strict sense. It assumes gas particles have no volume of their own and never attract each other. Those assumptions hold well for air, nitrogen and oxygen near room temperature and everyday pressures, which is why the model covers most questions people ask: tire pressure, tank capacity, balloon volume, breathing gas, lab stoichiometry.
What the equation does not do is tell you which variable to solve for. That is your job, and the four rearrangements are all one line of algebra each.
Worked example: one mole at standard conditions
Take one mole of any gas at 273.15 K, which is 0 °C, and one standard atmosphere of pressure, 101,325 Pa. Solve for volume: V = nRT / P.
The arithmetic is 1 x 8.314462618 x 273.15 / 101,325 = 0.02241397 cubic meters, which is 22.414 liters. That figure is the classic molar volume, and the NIST reference set lists 22.41396954 liters for exactly this temperature and pressure, so the agreement is not a coincidence.
Move the temperature to 25 °C and the same mole occupies 24.465 liters, a 9.2 percent larger volume. Nothing about the gas changed; warmer gas pushes out against the same pressure. This is the single most useful sanity check in the whole topic: if a calculation returns a molar volume far from 22 to 25 liters at ordinary conditions, something in the units is wrong.
| Conditions | Molar volume | Arithmetic |
|---|---|---|
| 273.15 K, 101.325 kPa | 22.414 L | 1 x 8.314462618 x 273.15 / 101325 |
| 298.15 K, 101.325 kPa | 24.465 L | 1 x 8.314462618 x 298.15 / 101325 |
| 273.15 K, 100 kPa | 22.711 L | 1 x 8.314462618 x 273.15 / 100000 |
| 300 K, 2 atm | 12.309 L | 1 x 8.314462618 x 300 / 202650 |
The third row matters more than it looks. Two different definitions of standard conditions are in use: 101.325 kPa comes from the old standard atmosphere, while 100 kPa is the current IUPAC standard pressure. They give molar volumes that differ by about 1.3 percent, so a textbook answer of 22.4 L and a database answer of 22.7 L can both be right.
Worked example: a 12 liter scuba tank
A steel scuba tank holds 12.0 liters of water volume and is filled to 200 atm at 20 °C. How much gas is inside? Here pressure and volume are known and the amount is the unknown: n = PV / RT.
Convert first. 200 atm is 200 x 101,325 = 20,265,000 Pa. The volume is 0.012 cubic meters. Temperature is 20 + 273.15 = 293.15 K. Then n = 20,265,000 x 0.012 / (8.314462618 x 293.15) = 243,180 / 2,437.4 = 99.77 moles.
Multiply by the molar mass of air, 28.97 grams per mole, and the tank holds about 2,890 grams of air, or 2.89 kilograms. Divers recognize the number: an aluminum 80 cubic foot tank at 3,000 psi carries a similar mass, and the arithmetic explains why tank pressure and tank size both matter.
Run the same tank down to 50 atm at the same temperature and the amount falls to 24.94 moles, one quarter of the fill. Pressure and amount are proportional when volume and temperature hold still, which is the part of the law that makes a pressure gauge a fuel gauge.
Temperature has to be absolute
Every wrong answer in this topic traces back to Celsius. The gas law uses kelvin, where zero means the point at which a gas would have no thermal energy at all. Add 273.15 to a Celsius reading and you are done, because the kelvin is defined from the Boltzmann constant and the triple point of water, as the NIST page on the kelvin sets out. Fahrenheit needs two steps: subtract 32, multiply by 5/9, then add 273.15.
The error is not small. Feed 20 °C as 20 into a volume calculation and the answer comes out about 14 times too large, because 20 is a number on an arbitrary scale, not a ratio.
A tire makes the point in a way drivers feel. A tire at 20 °C reads 32 psi on a gauge, which is 46.70 psi absolute once atmospheric pressure is added. Heat it to 60 °C with the volume fixed and the pressure scales with absolute temperature: 46.70 x 333.15 / 293.15 = 53.07 psi absolute, or 38.37 psi on the gauge. Six psi from a warm afternoon on the highway.
| Reading | Kelvin | What happens if you skip the conversion |
|---|---|---|
| 0 °C | 273.15 K | Division by zero, or a nonsense result |
| 20 °C | 293.15 K | Volume overstated by a factor of about 14.7 |
| 25 °C | 298.15 K | Molar volume comes out at 2.05 L instead of 24.47 L |
| 98.6 °F | 310.15 K | Two conversions needed, and both are easy to forget |
Gauge pressure has the same shape of problem. A tire gauge reads the difference between the inside and the outside, so absolute pressure is the gauge reading plus roughly 14.7 psi at sea level. The gas law only ever sees the absolute number.
Solving for each variable, and for density
Four rearrangements cover every question, and a fifth covers the one people ask most often in practice.
| Unknown | Rearranged law | Use case |
|---|---|---|
| Pressure | P = nRT / V | Tank pressure, sealed container heated up |
| Volume | V = nRT / P | Balloon size, gas produced by a reaction |
| Amount | n = PV / RT | How much gas is in a cylinder |
| Temperature | T = PV / nR | Flame temperature estimate, adiabatic checks |
| Density | rho = PM / RT | Buoyancy, leak rate, ventilation sizing |
Density is worth its own line because it is where the law meets a number you can weigh. Substitute n = m / M into PV = nRT, divide by volume, and density becomes pressure times molar mass over RT. For air at 25 °C and one atmosphere, 101,325 x 28.97 / (8.314462618 x 298.15) = 1,184 grams per cubic meter, or 1.184 grams per liter.
The same formula explains a party trick. Carbon dioxide has a molar mass of 44.01 grams per mole against 28.97 for air, so at 0 °C and one atmosphere it weighs 1.964 grams per liter, about 52 percent more than air. That is why carbon dioxide settles into low places and why a candle goes out in a jar of it.
For a mixture, use the average molar mass. Dry air is close to 78 percent nitrogen and 21 percent oxygen by volume, and the weighted average lands at 28.97 grams per mole. Getting that number right is the difference between a density within one percent and one that is off by a fifth.
Units that trip people up
The gas constant is not one number, it is one physical quantity expressed in different units. Pick the version that matches your inputs and no conversion is needed; mix units and the answer is wrong by a factor nobody notices.
| R value | Units | Pairs with |
|---|---|---|
| 8.314462618 | J per mole per kelvin | Pa and cubic meters |
| 8.3145 | L kPa per mole per kelvin | kPa and liters |
| 0.082057 | L atm per mole per kelvin | atm and liters |
| 62.3636 | L mmHg per mole per kelvin | mmHg and liters |
| 10.7316 | cubic feet psi per pound mole per degree Rankine | US engineering units |
Pressure conversions account for most of the remaining trouble. One atmosphere is 101.325 kPa, 760 mmHg, 14.6959 psi, and 1.01325 bar. The millimetre of mercury and the torr are the same size by definition, since one torr is exactly 101,325 / 760 pascals.
Two habits prevent nearly all unit errors. Write the units into the arithmetic and cancel them, and convert to pascals, cubic meters, moles and kelvin before touching the calculator, then convert the answer back. The widget on this page does the second automatically, which is also why its unit menus matter: the numbers inside are always SI.
When the ideal gas law stops working
The model fails in a predictable direction. It overestimates pressure when molecules are packed close enough to take up space, and underestimates it when they attract each other. Both happen at high pressure, low temperature, or both.
The practical rule of thumb used in engineering courses is that air behaves within a couple of percent of ideal at room temperature up to about 10 atmospheres. Compress a gas to 200 atm, as in a full scuba tank, and the ideal law overstates the amount of gas by a few percent; the real fill is a little less than the 99.77 moles calculated above. Near the boiling point of a gas, the error can reach tens of percent.
The standard fix is the compressibility factor Z, defined so that PV = ZnRT. Z is close to 1 for an ideal gas, above 1 when repulsion dominates, and below 1 when attraction dominates. Z values for common gases are tabulated by pressure and temperature, and a correction is a single multiplication once you have the table.
A more detailed fix is the van der Waals equation, which subtracts a volume term from V and adds an attraction term to P using two constants per gas. Steam near the boiling point, ammonia at pressure, and carbon dioxide above 30 °C all need one of these corrections. For a balloon, a bicycle tire, or a classroom stoichiometry problem, the ideal version is enough.
Gas mixtures and partial pressure
Mixtures follow the same law per component. Dalton's law says the total pressure of a mixture of gases that do not react is the sum of the partial pressures, and each partial pressure is the mole fraction times the total.
Dry air at sea level is 78.08 percent nitrogen, 20.95 percent oxygen and 0.93 percent argon by volume, with carbon dioxide at about 0.04 percent. At one atmosphere, oxygen's partial pressure is 0.2095 x 101.325 = 21.23 kPa, which is the number a respiratory therapist means by 21 percent oxygen. Add water vapor and the calculation needs the vapor pressure of water at body temperature, which is where the term partial pressure of oxygen in arterial blood comes from.
The same arithmetic sizes a gas blend. A nitrox mix at 32 percent oxygen in a tank at 200 atm gives an oxygen partial pressure of 64 atm, which is why divers track it: above about 1.4 atm of oxygen partial pressure, the risk of acute toxicity rises.
For a mixture with a known mass composition, convert each mass to moles first, add them, then take mole fractions. A 50 gram sample of 80 percent nitrogen and 20 percent oxygen by mass is 1.428 moles of nitrogen and 0.312 moles of oxygen, so the oxygen fraction by volume is 0.180, not 0.20.
Frequently asked questions
What is the ideal gas law?
PV = nRT, where P is pressure in pascals, V is volume in cubic meters, n is moles, R is 8.314462618 J per mole per kelvin, and T is temperature in kelvin. Solve for whichever one you do not know.
What is the value of R?
8.314462618 J mol^-1 K^-1, exact under the 2022 CODATA adjustment. In liters and atmospheres the same constant is 0.082057, and in liters and mmHg it is 62.3636.
How many liters is one mole of gas?
22.414 liters at 273.15 K and 101.325 kPa, and 24.465 liters at 25 °C and the same pressure. At the current IUPAC standard pressure of 100 kPa the figure is 22.711 liters.
Why does my answer come out wrong by a factor of 14?
You used Celsius. The law needs kelvin, so add 273.15. Entering 20 instead of 293.15 makes the volume about 14.7 times too large.
Can I use gauge pressure?
No. Convert to absolute first by adding atmospheric pressure, about 14.7 psi at sea level. A tire reading 32 psi is 46.70 psi absolute.
How much gas is in a 12 liter tank at 200 atm?
About 99.77 moles at 20 °C, which is roughly 2.89 kilograms of air. Real fills run slightly lower because air stops behaving ideally at that pressure.
How do I get density from the ideal gas law?
Density equals pressure times molar mass divided by RT. Air at 25 °C and one atmosphere works out to 1.184 grams per liter using a molar mass of 28.97 grams per mole.
Does temperature have to be in kelvin for density too?
Yes. The same absolute temperature requirement applies, since density is just the law rearranged with mass replacing moles.
When does the ideal gas law fail?
At high pressure, low temperature, or both. Air is within a couple of percent of ideal up to about 10 atm at room temperature; at 200 atm the ideal law overstates the amount of gas by a few percent.
What is the compressibility factor Z?
A correction that turns PV = nRT into PV = ZnRT. Z equals 1 for an ideal gas, above 1 when molecular volume dominates and below 1 when attraction dominates. It is tabulated by gas, pressure and temperature.
How do I find partial pressure in a mixture?
Multiply the mole fraction by the total pressure. Oxygen at 20.95 percent of one atmosphere has a partial pressure of 21.23 kPa.
Does the law work for steam?
Badly near the boiling point, where steam is close to condensing. Use steam tables or a real gas model instead, and treat any ideal gas answer within 20 °C of the boiling point as a rough estimate.
How many grams is a mole of air?
28.97 grams, from a weighted average of 78.08 percent nitrogen at 28.01 and 20.95 percent oxygen at 32.00. Carbon dioxide and argon add the small remainder.
Can I use this for a balloon that is inflating?
For a snapshot yes, with pressure, volume and temperature at one moment. As the balloon stretches, pressure and volume change together, so treat it as a series of snapshots rather than one calculation.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.