Gas Density Calculator

How dense is your gas at a given pressure and temperature?

Enter a gas pressure, temperature, and molar mass to get its density in kg/m3 and g/L. Works for any ideal gas including air, CO2, methane, and hydrogen. Useful for buoyancy, combustion, HVAC, and fluid dynamics calculations.

Updated June 2026 · How this works

Example calculation — edit any field to use your own numbers

Worth knowing
How It Works
The formula, explained simply

Imagine you have a sealed box of a fixed size. Pumping more gas molecules in makes the box heavier — more mass in the same volume means higher density. Heating that same box makes each molecule move faster and push harder, but does not add any mass. If the box can expand, the gas spreads out and density drops. If it cannot expand, pressure rises instead. This tension between pressure, temperature, and the amount of gas is exactly what the ideal gas law captures.

The formula rho = (P x M) / (R x T) has four variables and one constant. Pressure P pushes density up. Temperature T pushes density down. Molar mass M tells you how heavy each molecule is — heavier molecules pack more mass into the same number of moles. The gas constant R = 8.314 J per mol per K is fixed. What surprises most people is that two gases at the same pressure and temperature but different molar masses have density in direct proportion to their molar mass ratio: CO2 at 44 g/mol is exactly 44/28.97 times denser than air.

The result you get from this calculator is in kg per cubic meter, the SI standard for gas density. One kg/m3 is numerically identical to one gram per liter, which is useful for lab work. Air at room temperature sits at roughly 1.2 kg/m3. Helium at 0.164 kg/m3 is the reason balloons rise. Sulfur hexafluoride at 5.11 kg/m3 is why your voice drops when you inhale it — sound velocity depends on gas density.

When To Use This
Right tool, right situation

Use this calculator when you need to convert a volume of gas to a mass, check whether a released gas will rise or sink in a room, size a duct or pipe for a specific mass flow rate, verify a buoyancy calculation for a balloon or airship, or sanity-check a gas measurement against expected physical properties. It works well for air, nitrogen, oxygen, CO2, methane, hydrogen, helium, and any custom gas or mixture where you know the blended molar mass.

This calculator is appropriate for conditions ranging from near-vacuum to moderate pressures (under 5 MPa) and temperatures from -50 C to several thousand degrees C, as long as the gas remains well above its condensation point. Industrial gases in storage cylinders, atmospheric science calculations, and combustion analysis all fall within its reliable range.

Do not use this calculator for gases near their dew point or at supercritical conditions. Ammonia near 0 C, CO2 near its critical point (31 C, 7.4 MPa), and steam in low-quality zones all deviate significantly from ideal behavior. Do not use it for dense phase transport, liquefied gas calculations, or any situation where compressibility factor Z deviates from 1.0 by more than a few percent. At high pressures, a Peng-Robinson or Soave-Redlich-Kwong equation of state will give results accurate enough for engineering design.

Common Mistakes
Why results sometimes look wrong

The most common mistake is using gauge pressure instead of absolute pressure. A tire inflated to 30 PSI gauge is at 44.7 PSI absolute (adding 14.7 PSI for atmosphere). Using 30 PSI in the formula underestimates the actual gas density inside the tire by about 33%. Always add local atmospheric pressure to any gauge reading before entering it here.

A second frequent error is confusing molar mass of a mixture with the molar mass of the primary component. Natural gas is mostly methane (16 g/mol) but also contains ethane, propane, and CO2. The blended molar mass might be 17.5 to 19 g/mol depending on source. Using pure methane for a pipeline gas application understates density by 10 to 15%, which matters for mass flow metering.

A third mistake is forgetting that this calculator gives density at the specified conditions — not at standard conditions. If you measure a gas sample at 60 C and want to compare it to a reference density at 20 C, the numbers are not directly comparable. Gas density at 60 C is about 13% lower than at 20 C at the same pressure. Always state or convert conditions before comparing measurements or performing mass balance calculations.

The Math
Worked examples and deeper derivation

The ideal gas law in molar form is PV = nRT, where P is absolute pressure (Pa), V is volume (m3), n is the number of moles, R is 8.314 J per mol per K, and T is temperature in Kelvin. Density is mass divided by volume. Mass equals moles times molar mass M in kg/mol: m = nM. Substituting gives density rho = m/V = nM/V. From the ideal gas law, n/V = P/(RT). Therefore rho = PM/(RT).

Molar mass must be in kg/mol when using SI units. A common error is leaving M in g/mol, which gives density in g/m3 — three orders of magnitude off. The calculator converts your g/mol input internally. Absolute pressure is also essential: using gauge pressure (relative to atmosphere) will systematically underestimate density, and the error scales with how much above atmosphere your gauge reading is.

The moles per cubic meter output — n/V = P/(RT) — is independent of which gas you are looking at. At 20 C and 101,325 Pa, every ideal gas contains 41.57 mol per cubic meter regardless of its molar mass. This is a direct consequence of Avogadro's law. Specific volume, the reciprocal of density, appears in thermodynamic property tables and is convenient when calculating mass from a known volume.

Checking whether a CO2 leak will accumulate at floor level
CO2 (44.01 g/mol), 101,325 Pa, 25 C
Result: 1.785 kg/m3. Air at the same conditions is about 1.184 kg/m3, making CO2 roughly 1.51x denser than air. This means leaked CO2 will sink and pool at floor level rather than dispersing upward — a ventilation and safety concern in enclosed spaces like cellars or server rooms.
HVAC engineer sizing a duct for hot supply air
Dry air (28.97 g/mol), 101,325 Pa, 55 C
Result: approximately 1.076 kg/m3. Hot supply air is about 10% less dense than room-temperature air at 20 C (1.204 kg/m3). A duct system sized on mass flow must account for this lower density — the same volumetric flow rate carries less mass and less thermal energy than it would at cooler temperatures.
Aerospace student verifying hydrogen lift for a balloon design
Hydrogen H2 (2.016 g/mol), 101,325 Pa, 15 C
Result: approximately 0.085 kg/m3. Compared to air at the same conditions (1.225 kg/m3), hydrogen is about 14.4x lighter. Each cubic meter of hydrogen provides roughly 1.14 kg of net buoyant lift. For a balloon displacing 100 m3, that is about 114 kg of gross lift before subtracting envelope mass — confirming whether the design is physically viable.
Expert Unlock
The thing most explanations skip

The ideal gas law assumes point masses with no intermolecular forces, which breaks down in two directions at once at high pressure: molecules begin to repel each other (raising pressure above ideal) while attractive forces pull them together (lowering pressure). These effects cancel coincidentally at moderate pressures for many gases, which is why the ideal law works surprisingly well up to 3-5 MPa. The compressibility factor Z accounts for both: actual density equals rho_ideal divided by Z. For nitrogen at 200 bar and 20 C, Z is approximately 1.07 — the ideal law underestimates density by about 7%. For hydrogen at the same conditions, Z exceeds 1.06 due to dominant repulsive forces, while CO2 near its critical point sees Z drop to 0.27, making ideal law results nearly meaningless there.

Why does gas density change with temperature and pressure?

What is the formula for gas density using the ideal gas law?
Gas density equals pressure times molar mass divided by the universal gas constant times temperature in Kelvin: rho = (P x M) / (R x T). Pressure is in Pascals, molar mass in kg per mol, R is 8.314 J per mol per K, and T is in Kelvin (Celsius plus 273.15). This gives density in kg per cubic meter directly.
What is the density of air at standard temperature and pressure?
Dry air at 0 C and 101,325 Pa has a density of approximately 1.293 kg per cubic meter. At the more commonly used standard of 20 C and 101,325 Pa, air density drops to about 1.204 kg per cubic meter. Humidity lowers density slightly because water vapor (18 g/mol) is lighter than dry air (28.97 g/mol).
When does the ideal gas law give inaccurate gas density results?
The ideal gas law becomes unreliable at pressures above roughly 10 MPa, temperatures near the gas's boiling or condensation point, or when dealing with polar molecules at moderate densities. At these conditions, intermolecular forces and molecular volume matter — use a real-gas equation of state like Peng-Robinson or van der Waals instead.

Need something this doesn't cover?

Suggest a tool — we'll build it →