Gas Density Calculator - Rho from P, T, Molar Mass

Gas density calculator that solves the rearranged PV=nRT equation for rho in kg/m^3, g/L, and lb/ft^3 from pressure, temperature, and molar mass of the gas.

Gas Density Calculator

Absolute pressure of the gas. Use 101.325 kPa for standard sea-level conditions, 100 kPa for SATP, or the actual reading from a lab or weather station.

Temperature of the gas in the chosen unit. The ideal gas law needs absolute temperature, so the calculator adds 273.15 to Celsius or applies the Fahrenheit conversion when needed.

Select the unit that matches your pressure input. The calculator converts to pascals internally before applying the ideal gas law.

Use Kelvin for cryogenic and physics work, Celsius for room-temperature chemistry, or Fahrenheit for HVAC and weather applications.

Pick a common gas to auto-fill the molar mass, or choose Custom and enter your own value. The default Air preset uses the dry-air molar mass of 28.97 g/mol.

Molar mass of the gas in grams per mole. Auto-filled when you pick a gas above; edit freely when Custom is selected.

Results

Density
0kg/m^3
Density in g/L 0g/L
Density in lb/ft^3 0lb/ft^3
Ratio to air 0x air

What Is Gas Density?

The gas density calculator is a thermodynamics tool that solves the rearranged ideal gas law for the density of any gas from its pressure, temperature, and molar mass. Pick air, nitrogen, oxygen, helium, carbon dioxide, methane, or a custom molar mass and get the answer in kg/m^3, g/L, and lb/ft^3 without doing unit conversions by hand.

  • Chemistry homework and lab reports: Solve problems where you know the gas, pressure, and temperature and want the density in kg/m^3 or g/L.
  • Engineering and HVAC sizing: Estimate the mass of gas inside a tank, duct, or combustion chamber from the operating pressure and temperature.
  • Physics and intro-thermodynamics classes: Show how gas density responds to pressure and temperature changes and compare lighter-than-air versus heavier-than-air gases.
  • Aerostatics and buoyancy checks: Compare a candidate lifting gas against the surrounding air to see whether it will rise or sink.

Unlike the density of a solid or liquid, gas density changes sharply with pressure and temperature, which is why both state variables are required alongside molar mass.

When you need any one of P, V, n, or T instead of density, an ideal gas calculator solves the same PV=nRT equation for the missing state variable.

How This Calculator Works

The gas density calculator converts your pressure, temperature, and molar mass to SI base units (pascals, kelvin, kilograms per mole) and plugs them into the rearranged ideal gas law to return density in kilograms per cubic meter.

rho = M * P / (R * T)
  • rho: Density in kg/m^3.
  • M: Molar mass in kg/mol (the calculator divides your g/mol value by 1000).
  • P: Absolute pressure in pascals (converted from kPa, hPa, mbar, atm, bar, mmHg, inHg, or psi).
  • R: Universal gas constant, 8.314462618 J/(mol*K).
  • T: Absolute temperature in kelvin (273.15 added to Celsius, Fahrenheit converted).

The math starts with PV = nRT and substitutes n = m/M, giving PV = (m/M)RT. Dividing by V gives P = (rho/M)RT, and rearranging yields rho = MP/(RT).

Worked example: dry air at 25 C and 1 atm

P = 101.325 kPa, T = 25 C (298.15 K), M = 28.97 g/mol (0.02897 kg/mol)

rho = (0.02897 x 101325) / (8.314462618 x 298.15) = 2934.78 / 2478.94

rho = 1.184 kg/m^3 (1.184 g/L, 0.0739 lb/ft^3, ratio to air 1.000x)

Matches the published sea-level indoor dry-air density to four significant figures.

According to NIST CODATA 2018 Fundamental Constants, the universal gas constant R is fixed at 8.314462618 J/(mol x K) under the 2019 SI redefinition, which keeps the calculator aligned with modern metrology references.

According to the OpenStax Chemistry 2e textbook, the rearranged form rho = MP/(RT) follows directly from PV = nRT by substituting the mole count n = m/M and the density rho = m/V, which is the standard derivation taught in general chemistry and the same starting point the calculator uses.

For the humidity-aware dry-air case the air density calculator adds the water-vapor partial pressure using Tetens' equation on top of the same rho = MP/(RT) base.

Key Concepts Explained

Four ideas drive every answer the gas density calculator produces. Once you understand them, the outputs map directly onto the steps you would show on a worksheet.

Ideal gas law PV = nRT

Pressure times volume equals moles times the gas constant times absolute temperature. This parent equation is what gas density is rearranged from.

Molar mass and the mole concept

Molar mass M (g/mol) converts between gas mass and mole count n in the ideal gas law. It is the yardstick that lets you compare grams of one gas to grams of another.

Absolute temperature in Kelvin

Kelvin starts at absolute zero and is the only scale that makes PV = nRT work. Adding 273.15 to Celsius removes the negative values that would otherwise break the formula.

Pressure units and absolute versus gauge

The ideal gas law uses absolute pressure, not gauge pressure. A tire gauge reading 0 psi gauge is actually 14.7 psi absolute, so the tool expects an absolute reading.

For a custom mixture, the mole and molar mass calculator sums the periodic-table masses for the formula you typed in.

How to Use This Calculator

Pick a gas, enter pressure and temperature in any supported unit, and the gas density calculator returns the answer in three practical units at once.

  1. 1 Choose a gas: Use the Gas dropdown to pick air, nitrogen, oxygen, helium, CO2, methane, hydrogen, argon, or natural gas. The molar mass field auto-fills, or choose Custom to type your own.
  2. 2 Enter the pressure: Type the absolute pressure and pick the matching unit. Use 101.325 kPa for standard sea-level air or your actual barometer reading for weather-balloon work.
  3. 3 Enter the temperature: Type the temperature in Celsius, Fahrenheit, or Kelvin. The calculator converts to Kelvin internally so the formula stays consistent with the ideal gas law.
  4. 4 Override the molar mass if needed: Edit the molar mass field directly for custom mixtures or refrigerants. Air is 28.97 g/mol; pure nitrogen is 28.014 g/mol.
  5. 5 Read the three density values: Use kg/m^3 for SI physics, g/L for chemistry, and lb/ft^3 for US engineering work. All three update together as you change inputs.
  6. 6 Check the ratio to air: Compare the ratio-to-air readout to 1.000x. Below 1 means lighter than indoor air; above 1 means heavier and likely to sink.

To check whether a helium balloon will rise, pick the Helium preset, enter the room temperature (say 22 C) and pressure (say 101.0 kPa), and read the ratio to air. Helium at 22 C and 1 atm comes out around 0.139x, well below 1.000x, which is why a helium balloon ascends until the surrounding air thins enough to match its density.

If the worksheet instead wants Boyle's or Charles's law with pressure and volume held against each other, a gas laws calculator walks through that family of relationships next.

Benefits of Using This Calculator

This tool handles the tedious unit conversions and rearrangements, so you can spend more time on the decision that comes after you have the answer.

  • Three density units at once: Get kg/m^3, g/L, and lb/ft^3 in a single run for a physics lab, chemistry report, or HVAC sizing sheet.
  • Auto-filled molar mass for nine gases: Air, nitrogen, oxygen, helium, CO2, methane, hydrogen, argon, and natural gas all have built-in molar masses from IUPAC atomic weights.
  • Pressure and temperature unit freedom: Type pressure in any of nine units (Pa, kPa, hPa, mbar, atm, bar, mmHg, inHg, psi) and temperature in C, F, or K.
  • Built-in heavier/lighter-than-air check: The ratio-to-air readout tells you immediately whether the gas will rise or sink in still indoor air.
  • NIST-traceable gas constant: R = 8.314462618 J/(mol*K) from NIST CODATA 2018, consistent with every modern metrology reference.
  • Real-time recalculation on phones: Inputs update the outputs as you type, handy on a tablet in the lab or at the weather station.

If the ratio-to-air number looks close to 1.000x, that is a useful warning that the gas will neither rise nor sink readily, which matters for ventilation and confined-space safety calculations.

For altitude-dependent density work, the altitude temperature calculator converts elevation to the matching standard-atmosphere temperature so you can feed a realistic P and T into the working formula for each flight level.

Factors That Affect Your Results

The arithmetic is exact, but the assumptions baked into the ideal gas law decide how close the gas density calculator's answer is to a real laboratory measurement.

Pressure and temperature scale

Always use absolute pressure (not gauge) and Kelvin temperature (not Celsius). A 1% error in either input produces roughly a 1% error in density.

Molar mass of the gas mixture

Real gases are usually mixtures. Using 28.97 g/mol for dry air is a working value; humid air is lighter because water vapor (18.015 g/mol) replaces some heavier molecules.

Departure from ideal behavior

At very high pressure or very low temperature, real gases deviate from PV = nRT. The calculator is most accurate below about 10 bar and above about 200 K.

Real-gas effects near condensation

Close to the boiling point or critical temperature of a gas, intermolecular forces bend the density curve. Treat the output as a working value rather than a reference.

Unit choice for the user

If you type psi by accident when you meant atm, the density will be off by a factor of about 14.7. Always double-check the unit dropdown before trusting a wildly different answer.

  • Very dense gases (CO2 above 50 bar, propane, refrigerants near their critical point) need a compressibility-factor correction that this calculator does not apply.
  • Molar mass above about 100 g/mol (large organic vapors) and below about 2 g/mol (hydrogen isotopes) still works mathematically, but real-gas behavior dominates quickly.

Treat this tool as a working tool for chemistry homework, HVAC sizing, intro thermodynamics, and buoyancy checks. For high-pressure engineering or critical-point work, switch to an equation of state such as Peng-Robinson.

If the ratio-to-air number ends up above 1 for a gas you expected to be lighter, the most common culprit is forgetting to switch from gauge to absolute pressure on the input.

According to NASA Earth Fact Sheet, the mean molar mass of dry air is 28.9647 g/mol and standard sea-level pressure is 101.325 kPa, so the calculator's Air preset reproduces the textbook 1.184 kg/m^3 value at 25 C and 1 atm.

When the gas is humid air and you need to subtract the water-vapor mass from the dry-air mass to get a corrected density, the absolute humidity calculator reports the moisture content in g/m^3 to plug into the working formula.

Gas density calculator showing pressure, temperature, and molar mass inputs with density outputs in kg/m^3, g/L, and lb/ft^3 for any chosen gas.
Gas density calculator showing pressure, temperature, and molar mass inputs with density outputs in kg/m^3, g/L, and lb/ft^3 for any chosen gas.

Frequently Asked Questions

Q: What is the formula for gas density?

A: The gas density formula is rho = M * P / (R * T), where M is molar mass in kilograms per mole, P is absolute pressure in pascals, R = 8.314462618 J/(mol*K), and T is absolute temperature in kelvin. It comes from rearranging the ideal gas law PV = nRT using n = m/M and rho = m/V.

Q: How do you calculate the density of an ideal gas?

A: Convert pressure to pascals, temperature to kelvin, and molar mass to kilograms per mole, then plug into rho = M * P / (R * T). The calculator does all three conversions automatically and returns the density in kg/m^3, g/L, and lb/ft^3 at the same time.

Q: What is the density of air at 25 C and 1 atm?

A: Dry air with molar mass 28.97 g/mol at 101.325 kPa and 25 C has density (0.02897 x 101325) / (8.314462618 x 298.15) = 1.184 kg/m^3, which is also 1.184 g/L or about 0.0739 lb/ft^3.

Q: Is natural gas heavier than air?

A: No. Natural gas is mostly methane with molar mass around 17 g/mol, while dry air averages 28.97 g/mol, so natural gas is roughly 0.6 times as dense as air and rises rather than sinks when it leaks indoors. The calculator's ratio-to-air readout confirms this for any temperature and pressure you pick.

Q: What units does this tool report density in?

A: Inputs accept pressure in Pa, kPa, hPa, mbar, atm, bar, mmHg, inHg, or psi and temperature in Celsius, Fahrenheit, or Kelvin. Outputs report density in SI kg/m^3, chemistry-friendly g/L, and US-engineering lb/ft^3.

Q: When does the ideal gas law fail to predict gas density?

A: The ideal gas law loses accuracy above roughly 10 bar, below about 200 K, or near the critical point of a gas where intermolecular forces dominate. For high-pressure or near-condensation work, use a real-gas equation of state with a compressibility factor instead.