Gas Density Calculator Formula

Understand the math behind the gas density calculator. Each variable explained with a worked example.

Formulas Used

Gas Density

density = (pressure * molar_mass) / (0.08206 * temp)

Variables

VariableDescriptionDefault
pressurePressure (P)(atm)1
molar_massMolar Mass (M)(g/mol)28.97
tempTemperature (T)(K)273.15

How It Works

Gas Density from Ideal Gas Law

Formula

d = PM / (RT)

Where:

  • d = density (g/L)
  • P = pressure (atm)
  • M = molar mass (g/mol)
  • R = 0.08206 L·atm/(mol·K)
  • T = temperature (K)
  • Derived from PV = nRT by substituting n = mass/M and d = mass/V.

    Worked Example

    Calculate the density of air (avg M = 28.97 g/mol) at 1 atm and 273.15 K.

    pressure = 1molar_mass = 28.97temp = 273.15
    1. 01d = PM / (RT)
    2. 02d = (1)(28.97) / (0.08206 × 273.15)
    3. 03d = 28.97 / 22.414
    4. 04d = 1.292 g/L

    Frequently Asked Questions

    Why does gas density depend on pressure and temperature?

    Unlike liquids, gases are compressible. Higher pressure packs more molecules into a given volume, increasing density. Higher temperature expands gas, decreasing density.

    What is the density of air at STP?

    Air has an average molar mass of about 28.97 g/mol. At STP (1 atm, 273.15 K), its density is approximately 1.29 g/L.

    Can I use this for real gases?

    At moderate conditions it works well. For very high pressures or low temperatures, use the van der Waals equation or compressibility factor corrections.

    Ready to run the numbers?

    Open Gas Density Calculator