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.
—
Send feedback
💡 Share your idea or report a problem
✓ Thanks! We'll take a look.
Learn more
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.
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?
Need something this doesn't cover?
Suggest a tool — we'll build it →