Ideal Gas Law Solver
Solve PV = nRT for pressure, volume, temperature, or the amount of gas. Enter moles directly, or switch to mass and molar mass (type a chemical formula and the molar mass fills itself in), quick-fill STP, NTP, or room conditions, and see gas density and every calculation step.
Ideal Gas Law Diagram and Live Values
A sealed flask holding the gas, with pressure, volume, temperature, moles, and density (when a molar mass is known) shown live as PV = nRT.
Step-by-Step Solution
Here's exactly how this answer was calculated, one step at a time.
Given: P = 1 atm, V = 22.4 L, T = 273.15 K, n = 1 mol
Step 1: Convert temperature to kelvin
The ideal gas law always needs absolute temperature, so °C and °F are converted to kelvin first.
T = 0 °C → 273.15 KStep 2: Write the ideal gas law
PV = nRTStep 3: Rearrange for the unknown
P = nRT / VStep 4: Substitute and calculate
R is the universal gas constant, 0.082057 L·atm/(mol·K) here, which matches pressure in atmospheres and volume in litres.
P = (1 × 0.08206 × 273.15) ÷ 22.4 = 1.00062 atmStep 5: Convert to your chosen unit
The raw answer (in atm, L, K, or mol) is converted back into whichever unit you picked for that quantity.
Result = 1.00062 atm
The ideal gas law result is:
1.00062 atm
Free Ideal Gas Law Solver for Chemistry
This Ideal Gas Law Solver works out pressure, volume, temperature, or the amount of gas using PV = nRT, the equation every chemistry student meets sooner or later. Pick what you want to find, fill in the three values you already know, and the solver does the algebra for you and shows every step so you can check your own working or learn the method.
What makes this version built for chemistry rather than physics is how it handles the amount of gas. You don't always know the moles of a gas sitting in a flask — you usually know its mass. So instead of forcing you to convert mass to moles by hand, you can type the mass and either a molar mass or a chemical formula like CO2 or C3H8, and the solver works out the molar mass and the moles for you automatically.
The Ideal Gas Law Formula: PV = nRT
The ideal gas equation is PV = nRT, where P is pressure, V is volume, n is the number of moles of gas, T is absolute temperature, and R is the universal gas constant. In chemistry, the most common value used is R = 0.0821 L·atm/(mol·K), which matches pressure measured in atmospheres and volume measured in litres — that's the convention this solver uses internally, even though you're free to enter your numbers in kPa, mmHg, mL, cubic metres, or whatever unit your textbook or lab sheet gives you.
Temperature always has to be absolute temperature, measured in kelvin, never Celsius or Fahrenheit directly. The solver converts your °C or °F entry to kelvin automatically using T(K) = T(°C) + 273.15, so you never have to remember to do that step yourself, though it's shown clearly in the solution steps for anyone who wants to see the working.
How to Use This Solver
Start by choosing what you're solving for at the top: pressure, volume, temperature, or amount of gas. The solver hides that field, since it's the answer, and shows the other three so you can fill them in. Pick sensible units for each — atm or kPa for pressure, litres or millilitres for volume, °C or K for temperature — and the unit dropdowns take care of the conversion behind the scenes.
For the amount of gas, you get a choice: enter moles directly if you already know them, or switch to 'Enter mass + molar mass' if you only know how many grams of gas you're working with. In mass mode, you can either type a molar mass yourself or type a chemical formula in the formula box, and the solver reads the formula, works out its molar mass from atomic masses, and uses that automatically — so you don't need a periodic table open in another tab.
Worked Example: Moles of Gas at STP
Suppose a flask holds 44 grams of carbon dioxide at STP conditions — 0°C and 1 atm — and you want to know what volume it takes up. Set the solver to solve for volume, click the STP preset to fill in 0°C and 1 atm automatically, switch to 'Enter mass + molar mass', type 44 for the mass, and type CO2 in the formula box. The solver reads CO2 as one carbon atom and two oxygen atoms, works out a molar mass of about 44.01 g/mol, which gives 44 ÷ 44.01 ≈ 1 mole of gas.
With n ≈ 1 mol, T = 273.15 K, and P = 1 atm, the solver applies V = nRT/P and returns a volume of about 22.4 litres — the well-known 'molar volume of a gas at STP' figure that shows up in almost every introductory chemistry course. Because every step is shown underneath the result, you can follow exactly how the mass was turned into moles and then into a final volume.
STP, NTP, and SATP — What's the Difference?
Gas calculations often refer to a standard set of conditions instead of spelling out a temperature and pressure every time, and there's more than one standard in use, which trips a lot of people up. STP (Standard Temperature and Pressure) traditionally means 0°C and 1 atm, though the IUPAC definition changed the pressure to exactly 100 kPa, which is a fraction lower than 1 atm. NTP (Normal Temperature and Pressure) usually means 20°C and 1 atm, closer to a typical lab bench temperature. SATP, or simply 'room temperature and pressure', is commonly taken as 25°C and 1 atm.
Because textbooks and exam boards don't always agree on which definition they mean by 'STP', this solver gives you one-click buttons for the classic STP, the IUPAC STP, NTP, and room temperature/SATP, so you can quickly check how much the answer shifts between conventions, or just make sure you're using the same one your course expects.
Working with Mass, Moles, and Molar Mass
Real gas samples are usually weighed, not counted in moles directly, so converting between mass and moles is one of the most common steps in gas-law problems. The relationship is simple: moles = mass ÷ molar mass. The tricky part is usually finding the molar mass in the first place, which normally means adding up atomic masses for every atom in the formula — easy for O2, more fiddly for something like C6H12O6 or Ca(OH)2 with brackets and subscripts.
That's exactly what the formula box in this solver handles. Type a formula — including nested brackets like Ca(OH)2 or Al2(SO4)3 — and it parses each element and subscript, looks up standard atomic masses, and adds them together to give you the molar mass instantly. If you'd rather just type a molar mass you already know, or if the formula isn't recognised, you can fall back to typing the number directly into the molar mass field, and the solver will use that instead.
Gas Density from the Ideal Gas Law
Once a molar mass is known, the ideal gas law can also give you the density of the gas at whatever pressure and temperature you're working with, using the relationship ρ = PM/(RT), where M is molar mass. This solver calculates that automatically as an extra result whenever a molar mass is available, whether you typed it in directly, picked a gas preset, or entered a formula.
Gas density calculated this way is genuinely useful — it's how you can check whether an unknown gas might float or sink relative to air, estimate how much a gas cylinder of a known volume weighs, or sanity-check a lab measurement. Because density from PV = nRT depends on temperature and pressure, the same gas will show a different density on a cold day than a hot one, which is worth keeping in mind if you're comparing two density figures measured under different conditions.
Common Gas Presets
To save you looking up molar masses for the gases that show up most often in coursework, the solver includes quick-fill buttons for air, oxygen, nitrogen, carbon dioxide, hydrogen, helium, methane, ammonia, chlorine, and sulfur dioxide. Clicking one fills in the formula (or, for air, the molar mass directly, since air is a mixture rather than a single compound) so you can jump straight to your pressure, volume, or temperature numbers without typing a formula by hand.
These presets are also a handy way to double-check your own formula typing — if you type CO2 yourself and the molar mass shown doesn't match roughly 44 g/mol, you can compare it against the CO2 preset button to spot a typo quickly.
When Does a Gas Stop Behaving Ideally?
The ideal gas law assumes gas particles take up no volume themselves and don't attract or repel each other, which is a very good approximation at low pressure and high temperature, where particles are spread far apart and moving fast. Most classroom and lab problems sit comfortably inside that range, which is why PV = nRT gives answers close enough to reality for everyday chemistry work.
Real gases deviate more noticeably at high pressure or low temperature, especially as a gas approaches the conditions where it would condense into a liquid — carbon dioxide, ammonia, and sulfur dioxide are common examples that show measurable real-gas behaviour under everyday lab conditions. For more demanding engineering or industrial calculations, a real-gas equation such as van der Waals, or a compressibility factor, gives a more accurate result than the ideal gas law alone.
Where This Calculation Shows Up
PV = nRT is one of the most frequently used equations in general chemistry, and it underpins a lot of practical work beyond the classroom too: figuring out how much gas a reaction produces, checking the pressure inside a sealed container as temperature changes, working out how much oxygen is left in a scuba tank, sizing gas storage or piping, or estimating the volume a weather balloon will reach at altitude.
It also connects directly to stoichiometry — once you know the moles of a gas produced or consumed in a reaction, the ideal gas law lets you turn that into a real volume you could measure with a graduated cylinder or gas syringe, and vice versa. That's why gas-law and stoichiometry questions so often appear together on chemistry exams.
Ideal Gas Law Solver: Quick Reference
PV = nRT, rearranged as P = nRT/V, V = nRT/P, T = PV/(nR), or n = PV/(RT) depending on what you need. Always use absolute temperature in kelvin, keep pressure and volume units consistent with the R value you're using (atm and litres for R = 0.0821), and convert mass to moles with moles = mass ÷ molar mass when you're starting from a weighed sample rather than a mole count.
This solver is built for educational and lab-planning use. For safety-critical work involving pressurised gas, always follow your institution's validated procedures and rated equipment specifications rather than relying on an ideal-gas estimate alone.
Frequently Asked Questions
What is the ideal gas law formula?
PV = nRT, where P is pressure, V is volume, n is moles of gas, R is the gas constant, and T is absolute temperature in kelvin.
What value of R does this solver use?
R = 0.0821 L·atm/(mol·K), the standard value used throughout general chemistry. Enter your numbers in whatever unit you like — the solver converts internally.
How do I convert mass to moles for the ideal gas law?
Divide the mass of the gas by its molar mass: moles = mass ÷ molar mass. Switch to 'Enter mass + molar mass' and either type a molar mass or a chemical formula, and this solver does that division for you.
What is STP in chemistry?
STP traditionally means 0°C and 1 atm. The IUPAC definition uses 0°C and 100 kPa instead, which is slightly lower pressure. This solver has quick-fill buttons for both, plus NTP and room temperature (SATP).
Why does temperature have to be in kelvin?
The ideal gas law needs absolute temperature, measured from absolute zero, not from the freezing point of water. Using Celsius or Fahrenheit directly would give a meaningless answer.
Can I find the density of a gas with this calculator?
Yes. Once a molar mass is known (typed directly, picked from a preset, or read from a chemical formula), the solver calculates gas density automatically using ρ = PM/(RT).
Does the ideal gas law work for all gases?
It's a very good approximation for most gases at everyday pressure and temperature. It becomes less accurate at high pressure or low temperature, especially for gases like CO2 or NH3 that are closer to condensing.
What is the molar volume of a gas at STP?
About 22.4 litres per mole at classic STP (0°C, 1 atm), and about 22.7 litres per mole at IUPAC STP (0°C, 100 kPa) — this solver will calculate the exact figure for any gas and any conditions you enter.