Gas Density Calculator & Formula
- Specific volume
- m³/kg
- Result
- Molar mass
- 28.97 g/mol
- You entered
- Pressure
- 101.325 kPa
- You entered
This gas density calculator determines the density of an ideal gas from its molar mass, pressure, and temperature. You enter the gas’s molar mass (g/mol), the absolute pressure, and the temperature, and it returns the density in kg/m³ (or g/L). The calculation uses the ideal gas law rearranged to solve for density, giving you a quick, accurate estimate for most engineering and science applications.
Formula
The density of a gas is calculated from the ideal gas law, PV = nRT, by replacing n (moles) with mass divided by molar mass. Rearranging gives:
� = (M × P) / (R × T)
- � = gas density (kg/m³)
- M = molar mass of the gas (kg/mol; the calculator takes g/mol and divides by 1000)
- P = absolute pressure (Pa; the calculator takes kPa and multiplies by 1000)
- R = universal gas constant = 8.314 J/(mol·K)
- T = absolute temperature (K; the calculator adds 273.15 to the Celsius input)
This formula assumes the gas behaves ideally, which is a good approximation for most gases at moderate pressures and temperatures well above their boiling point.
Worked Example
Using the default values – molar mass of air (28.97 g/mol), pressure of 101.325 kPa (standard atmospheric pressure), and temperature of 20°C – we calculate:
- Convert molar mass to kg/mol: 28.97 g/mol ÷ 1000 = 0.02897 kg/mol
- Convert pressure to Pa: 101.325 kPa × 1000 = 101325 Pa
- Convert temperature to K: 20°C + 273.15 = 293.15 K
- Apply the formula: � = (0.02897 × 101325) / (8.314 × 293.15)
- Numerator: 0.02897 × 101325 = 2935.4
- Denominator: 8.314 × 293.15 = 2437.1
- Density = 2935.4 / 2437.1 = 1.204 kg/m³
The calculator shows 1.204 kg/m³, which matches the well-known density of air at 20°C and 1 atm.
When to Use the Ideal Gas Density
This calculator is useful for estimating the density of gases in many practical situations:
- Determining buoyancy for balloons or airships (compare with surrounding air density)
- Calculating mass flow rates in pipes when you know volumetric flow
- Designing ventilation systems where air density affects fan performance
- Converting between mass and volume fractions in gas mixtures
- Checking if a gas will rise or sink in a given environment
For most engineering work at near-ambient conditions (0–100°C, up to a few bar), the ideal gas law gives results within a few percent of reality.
How to Read the Result
The density output is in kilograms per cubic meter (kg/m³). For reference, air at sea level and 15°C has a density of about 1.225 kg/m³. Helium is much lighter (about 0.178 kg/m³ at 0°C, 1 atm), while carbon dioxide is heavier (about 1.98 kg/m³ at 0°C). The specific volume output is simply the inverse of density – the volume occupied by one kilogram of gas – useful for sizing tanks or compressors.
Remember that gas density changes significantly with temperature and pressure. A gas that is denser than air at room temperature may become lighter when heated, which is why hot air balloons rise.
Common Mistakes and Misconceptions
Here are the most frequent errors people make when calculating gas density:
- Using gauge pressure instead of absolute. The formula requires absolute pressure. If you have gauge pressure (relative to atmosphere), add atmospheric pressure (≈101.3 kPa) first.
- Forgetting to convert temperature to Kelvin. Adding 273.15 is essential; using Celsius directly gives wildly wrong results.
- Mixing up molar mass units. The calculator expects g/mol, but if you use kg/mol (e.g., 0.02897) without adjusting, the result will be off by a factor of 1000.
- Assuming ideal behavior at high pressure or low temperature. Near the condensation point, real gases deviate significantly. For example, CO₂ at 50°C and 50 bar is about 10% denser than ideal gas predicts.
- Confusing density with specific weight. Density is mass per volume; specific weight is weight per volume (density × gravity).
Limitations of the Ideal Gas Law
The ideal gas law is a simplification. It works best for:
- Low pressures (much less than the critical pressure)
- High temperatures (well above the boiling point)
- Non-polar, simple molecules (noble gases, air, Nâ‚‚, Oâ‚‚, Hâ‚‚)
For real gases, the compressibility factor Z is introduced: � = (M × P) / (Z × R × T). Z is less than 1 for attractive forces (typical at moderate pressures) and greater than 1 for repulsive forces (very high pressure). At 20°C and 101.325 kPa, Z for air is 0.9997 – nearly 1. But at 100 bar, Z for nitrogen is about 1.05, meaning the ideal gas law overestimates density by 5%. For accurate results under extreme conditions, use a real gas equation of state or look up experimental data.
Alternatives and Related Calculations
If you need more precision or different properties, consider these alternatives:
- Real gas calculators using van der Waals, Redlich-Kwong, or Peng-Robinson equations – better for high pressure or near-critical conditions.
- Gas mixture density – compute the average molar mass of the mixture (weighted by mole fractions) and use the same formula.
- Relative density (specific gravity) – divide the gas density by the density of air at the same conditions, giving a dimensionless number.
- Density at standard conditions – many industries report gas density at STP (0°C, 1 atm) or NTP (20°C, 1 atm). You can use this calculator with those fixed inputs.
Frequently Asked Questions
What is the density of air at room temperature?
At 20°C (293.15 K) and 101.325 kPa, air density is about 1.204 kg/m³. This varies with humidity – moist air is less dense than dry air because water vapor has a lower molar mass (18.02 g/mol) than air (28.97 g/mol).
How does altitude affect gas density?
As altitude increases, pressure decreases roughly exponentially, so density drops correspondingly. At 5,000 meters, air density is about half that at sea level. Temperature also decreases with altitude, which partially offsets the pressure effect, but pressure dominates.
Can I use this calculator for any gas?
Yes, as long as you know the molar mass and the gas behaves ideally. For common gases like oxygen (32 g/mol), nitrogen (28.02 g/mol), helium (4 g/mol), or carbon dioxide (44.01 g/mol), the ideal gas law is accurate at ambient conditions.
What is the difference between density and specific volume?
Density is mass per unit volume (kg/m³). Specific volume is volume per unit mass (m³/kg). They are reciprocals of each other. Specific volume is often used in thermodynamics and compressor calculations because it directly relates to the volume a given mass occupies.
Why does humidity make air less dense?
Water vapor has a molar mass of 18.02 g/mol, while dry air has an average molar mass of about 28.97 g/mol. When water vapor replaces some of the nitrogen and oxygen molecules, the average molar mass of the mixture decreases. At the same temperature and pressure, a lower molar mass means lower density.
What is the molar mass of air?
Dry air is a mixture: about 78% nitrogen (28.02 g/mol), 21% oxygen (32.00 g/mol), and 1% argon (39.95 g/mol) plus trace gases. The weighted average is approximately 28.97 g/mol. This value is used in the calculator’s default.
Related
Formula used
in m | Molar mass | g/mol | 28.97 | 0 in p | Pressure | kPa | 101.325 | 0 in t | Temperature | °C | 20 | -273.15 out d | Density | kg/m³ | (m / 1000) * (p * 1000) / (8.314 * (t + 273.15)) | 3 out v | Specific volume | m³/kg | 1 / d | 3
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.