How to Calculate Density of a Gas

Finding Density From Pressure

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

Density is mass per unit volume. 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 gases is that you are often given pressures and temperatures with no mention of volume. You have to figure it out from the other information.

How to Find Density of a Gas

  • Calculating the density of a gas usually involves combining the formula for density (mass divided by volume) and the ideal gas law (PV = nRT).
  • ρ = PM/RT, where M is molar mass.
  • The ideal gas law is a good approximation of the behavior of real gases.
  • Usually, with this type of problem, you are given the type of gas and enough other variables to solve the ideal gas law problem.
  • Remember to convert temperature to absolute temperature and watch your other units.

Density of a Gas Example Calculation

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.

Another Example

Calculate the density of carbon dioxide gas in the troposphere, knowing the temperature is -60.0 °C and the pressure is 100.0 millibar.

First, list what you know:

  • P = 100 mbar
  • T = -60.0 °C
  • R = 0.0821 L·atm/mol·K
  • carbon dioxide is CO2

Right off the bat, you can see some units don't match up and that you need to use the periodic table to find the molar mass of carbon dioxide. Let's start with that.

  • carbon mass = 12.0 g/mol
  • oxygen mass = 16.0 g/mol

There is one carbon atom and two oxygen atoms, so the molar mass (M) of CO2 is 12.0 + (2 x 16.0) = 44.0 g/mol

Converting mbar to atm, you get 100 mbar = 0.098 atm. Converting °C to K, you get -60.0 °C = 213.15 K.

Finally, all of the units agree with those found in the ideal gas constant:

  • P = 0.98 atm
  • T = 213.15 K
  • R = 0.0821 L·atm/mol·K
  • M = 44.0 g/mol

Now, plug the values into the equation for the density of a gas:

ρ = PM/RT = (0.098 atm)(44.0 g/mol) / (0.0821 L·atm/mol·K)(213.15 K) = 0.27 g/L


  • Anderson, John D. (1984). Fundamentals of Aerodynamics. McGraw-Hill Higher Education. ISBN 978-0-07-001656-9.
  • John, James (1984). Gas Dynamics. Allyn and Bacon. ISBN 978-0-205-08014-4.
  • Khotimah, Siti Nurul; Viridi, Sparisoma (2011). "Partition function of 1-, 2-, and 3-D monatomic ideal gas: A simple and comprehensive review". Jurnal Pengajaran Fisika Sekolah Menengah. 2 (2): 15–18. 
  • Sharma, P. V. (1997). Environmental and Engineering Geophysics. Cambridge University Press. ISBN 9781139171168. doi:10.1017/CBO9781139171168
  • Young, Hugh D.; Freedman, Roger A. (2012). University Physics with Modern Physics. Addison-Wesley. ISBN 978-0-321-69686-1.
mla apa chicago
Your Citation
Helmenstine, Anne Marie, Ph.D. "How to Calculate Density of a Gas." ThoughtCo, Apr. 4, 2022, Helmenstine, Anne Marie, Ph.D. (2022, April 4). How to Calculate Density of a Gas. Retrieved from Helmenstine, Anne Marie, Ph.D. "How to Calculate Density of a Gas." ThoughtCo. (accessed May 28, 2023).