ρ = P·M / (R·T)R = 8.314 J/(mol·K)  ·  dry air: M ≈ 28.97 g/mol

Gas density is the mass per unit volume of an ideal gas, fixed by its pressure, molar mass and absolute temperature through ρ = PM/RT. This free calculator solves for density, pressure, molar mass or temperature, and shows every step.

How to calculate gas density

The density of a gas is its mass packed into each unit of volume, and for an ideal gas it follows straight from the ideal gas law. Starting from PV = nRT and writing the amount of substance as mass divided by molar mass, the density rearranges to ρ = PM/(RT), where M is the molar mass and R is the universal gas constant, 8.314 J/(mol·K). The answer comes out in kilograms per cubic metre.

There are three steps. First, decide which quantity you want — density, pressure, molar mass or temperature — and select it in the calculator's Solve for menu. Second, enter the values you know: the pressure (Pa, kPa, atm or bar), the molar mass in grams per mole, and the temperature in kelvin, °C or °F. The temperature must be absolute, so the calculator converts °C and °F to kelvin for you before applying the formula. Third, read the answer with the worked steps, which show the formula, your numbers substituted in, and the result with units.

Because density rises with pressure and molar mass but falls with temperature, keeping the units consistent matters. This tool takes molar mass in g/mol and works internally in SI, so a value such as 28.97 g/mol for air becomes 0.02897 kg/mol automatically. The formula is a direct consequence of the ideal gas law, and it shares its definition of mass over volume with the general density calculator. For the term itself, see the physics glossary.

Worked example

Take dry air at sea level: pressure P = 101 325 Pa, temperature T = 288.15 K (15 °C), and molar mass M = 28.97 g/mol = 0.02897 kg/mol. Substituting gives ρ = (101325 × 0.02897) / (8.314 × 288.15) ≈ 1.225 kg/m³. This is the standard International Standard Atmosphere (ISA) sea-level air density, the reference value engineers use for lift, drag and aerodynamic calculations.

Why it matters

Gas density drives buoyancy and lift — hot-air balloons, aircraft wings and chimney draught all depend on the difference between a gas's density and its surroundings, which is exactly what the buoyancy calculator quantifies. It also governs HVAC and flue-gas flow, scuba and altitude physiology, and meteorology, where the effective air density behind an aircraft's performance is expressed as density altitude. Lighter gases such as hydrogen and helium, with molar masses far below air's 28.97 g/mol, are much less dense than the atmosphere and so rise.

Frequently asked questions

What is the formula for gas density?

For an ideal gas, density is rho = PM/RT — the pressure times the molar mass, divided by the universal gas constant times the absolute temperature. It follows directly from the ideal gas law PV = nRT once you replace the amount of substance with mass over molar mass.

What is the density of air at room temperature?

Dry air is about 1.2 kg/m^3 at 20 °C and about 1.29 kg/m^3 at 0 °C, both at sea-level pressure of 101.3 kPa. Density falls as the air warms, because gas density is inversely proportional to absolute temperature.

What molar mass should I use for air?

Use about 28.97 g/mol for dry air. That figure is a weighted average of its components — roughly 78% nitrogen (28 g/mol), 21% oxygen (32 g/mol) and 1% argon (40 g/mol). Humid air is slightly less dense because water vapour (18 g/mol) is lighter than dry air.

Why must temperature be in kelvin?

Gas density is inversely proportional to absolute temperature, so the zero point of the scale must be absolute zero rather than an arbitrary value. Convert with K = °C + 273.15 before using the formula. This calculator accepts °C and °F but converts them to kelvin first.

Should I use gauge or absolute pressure?

Always use absolute pressure, measured from a vacuum. If you have a gauge reading, add atmospheric pressure — about 101.3 kPa — before applying the formula, since the gas law depends on the true pressure of the gas, not the excess over the surroundings.

References & formula source

  • Halliday, Resnick & Walker — Fundamentals of Physics, Chapter 19 (The Kinetic Theory of Gases).
  • Young & Freedman — University Physics with Modern Physics, §18.1 (Equations of State).
  • Cengel & Boles — Thermodynamics: An Engineering Approach (ideal-gas property tables).
  • Further reading: Density of air — Wikipedia

Embed this calculator

Add this free Gas Density calculator to your own website — copy the snippet below.