How to Calculate Density of a Gas

Worked Example Problem

Most of the time, the Ideal Gas Law can be used to make calculations for real gases.
Most of the time, the Ideal Gas Law can be used to make calculations for real gases. Ben Edwards, Getty Images

Finding the density of a gas is the same as finding the density of a solid or liquid. You have to know the mass and the volume of the gas. The tricky part with gasses, you are often given pressures and temperatures with no mention of volume.

This example problem will show how to calculate density of a gas when given the type of gas, the pressure and the temperature.

Question: What is the density of oxygen gas at 5 atm and 27 °C?

First, let's write down what we know:

Gas is oxygen gas or O2.
Pressure is 5 atm
Temperature is 27 °C

Let's start with the Ideal Gas Law formula.

PV = nRT

P = pressure
V = volume
n = number of moles of gas
R = Gas constant (0.0821 L·atm/mol·K)
T = absolute temperature

If we solve the equation for volume, we get:

V = (nRT)/P

We know everything we need to find the volume now except the number of moles of gas. To find this, remember the relationship between number of moles and mass.

n = m/MM

n = number of moles of gas
m = mass of gas
MM = molecular mass of the gas

This is helpful since we needed to find the mass and we know the molecular mass of oxygen gas. If we substitute for n in the first equation, we get:

V = (mRT)/(MMP)

Divide both sides by m:

V/m = (RT)/(MMP)

But density is m/V, so flip the equation over to get:

m/V = (MMP)/(RT) = density of the gas.

Now we need to insert the values we know.

MM of oxygen gas or O2 is 16+16 = 32 grams/mole
P = 5 atm
T = 27 °C, but we need absolute temperature.

TK = TC + 273
T = 27 + 273 = 300 K

m/V = (32 g/mol · 5 atm)/(0.0821 L·atm/mol·K · 300 K)
m/V = 160/24.63 g/L
m/V = 6.5 g/L

Answer: The density of the oxygen gas is 6.5 g/L.