ForHosting KIT · Science

Gas density calculator

Dry air at 101325 Pa and 273.15 K weighs about 1.29 kg per cubic metre. Enter absolute pressure, molar mass and kelvin temperature to get the ideal-gas density, plus the P·M and R·T products to check your working. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Pressure
101,325
Molar mass
0.0289647
Creativity
273.15
You get
Gas constant
8.314462618
Density
1.2922610581
Product pm
2,934.8482275
Product rt
2,271.09546411

Ideal-gas mass density follows directly from the equation of state when you rearrange PV = nRT into mass per unit volume. Non-positive temperature is rejected because absolute zero and below are outside the model and would divide by zero at T equals zero.

How ideal-gas density follows from PV = nRT

Start from the ideal-gas law PV equals nRT, where P is absolute pressure, V is volume, n is amount of substance in moles, R is the universal gas constant, and T is absolute temperature in kelvin. The mass m of the sample is n times the molar mass M, so n equals m over M. Substitute into the equation of state to obtain PV equals (m/M) RT, then rearrange for mass over volume: m/V equals P M over R T.

That quotient is the mass density rho. In SI units you typically send P in pascals, M in kilograms per mole, T in kelvin, and leave R at the default 8.314462618 joules per mole per kelvin, which yields density in kilograms per cubic metre. The tool does not convert Celsius or Fahrenheit to kelvin, does not apply compressibility factors for real gases, does not mix species beyond a single effective molar mass you already chose, and does not solve Boyle or Charles problems that omit molar mass.

Absolute temperature must be strictly positive: T less than or equal to zero is rejected with invalid input instead of returning infinity or a meaningless negative density.

Where gas density calculations show up in real work

Secondary-school chemistry and physics courses constantly assign ideal-gas density problems that give P, M, and T and ask for rho, often for air balloons, tank fill estimates, or comparing light versus heavy gases at the same state. University general-chemistry and introductory thermo labs use the same three-number reduction before introducing real-gas equations of state and mixture rules. Process technicians and HVAC trainees sanity-check approximate gas density for duct mass-flow estimates when only absolute pressure, composition via molar mass, and temperature are known.

If you later need Boyle's law without molar mass, hydrostatic liquid pressure from fluid density, unit conversion between atmospheres and pascals, Kelvin conversion from Celsius, or compressibility-factor corrections, treat those as separate search intents and landings rather than overloading this gas density calculator page.

Homework and lab answer keys

Compute rho = PM/RT for textbook air, oxygen, and hydrogen states so teachers and auto-graders share one ground truth, including the non-positive temperature rejection.

Balloon and tank density estimates

Estimate ideal-gas mass density from measured absolute pressure, known molar mass, and absolute temperature before mass-flow or buoyancy checks.

What formula does this gas density calculator use?

rho = P · M / (R · T).

What happens if temperature is zero or negative?

Non-positive absolute temperature is not allowed under the ideal-gas density model rho = PM/RT.

Is the gas constant required?

Provide your own positive R when working in a non-SI consistent unit set.

What does it cost?

The browser tool is free and runs locally.

Can I work in atmospheres instead of pascals?

Yes, as long as you also enter a gas constant in matching units, such as 0.08205746 L·atm/(mol·K). Nothing is converted behind the scenes, so the density comes out in whatever unit system you chose.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/thermo/gas-density

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/thermo/gas-density \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pressure":101325,"molar_mass":0.0289647,"temperature":273.15}'
{
  "pressure": 101325,
  "molar_mass": 0.0289647,
  "temperature": 273.15
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "thermo.gas_density",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

With molar mass M equal to total mass divided by amount of substance, the density rho is pressure times molar mass divided by the product of the gas constant and absolute temperature: rho equals P times M over R times T. This calculator takes absolute pressure, molar mass, and absolute temperature—plus an optional gas constant that defaults to the SI value 8.314462618 joules per mole per kelvin—and returns the density together with the intermediate products P·M and R·T so you can check intermediate algebra on homework sheets.

How ideal-gas density follows from PV = nRT

Chemistry worksheets sometimes use atmospheres, grams per mole, and R equals 0.08205746 litre atmospheres per mole per kelvin; this calculator accepts an explicit gas_constant so those consistent systems still work without hidden unit conversion.

What you send and what you get back

Classic textbook checks include dry air near one atmosphere and zero Celsius recovering roughly 1.29 kilograms per cubic metre, oxygen at room temperature with M equals 0.032 kilograms per mole, and explicit R when working in litre-atmosphere units. Send finite numbers under the fields pressure, molar_mass, and temperature. pressure is absolute pressure in any unit consistent with your choice of R; it must be positive. molar_mass is the molar mass of the pure gas or the effective molar mass of a mixture and must be positive—dry air is about 0.0289647 kilograms per mole in SI. temperature is absolute temperature in kelvin and must be greater than zero; zero or negative values fail with a message that names the non-positive temperature rule. gas_constant is optional: when omitted the engine uses 8.314462618 and sets gas_constant_defaulted to true; when provided it must be a finite positive number and gas_constant_defaulted is false. Missing fields, non-numeric strings, NaN, and Infinity fail with invalid_input and are not charged. On success the response echoes cleaned pressure, molar_mass, temperature, and gas_constant, reports density as P·M/(R·T), includes product_pm and product_rt for intermediate checks, states the unit convention for SI, and includes the formula string and method ideal_gas_density. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.

Where gas density calculations show up in real work

Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.

Curriculum widgets and API fixtures

Drive browser demos and CI golden tests from the same isomorphic solver so classroom tools never disagree with backend grading.

What units should I use?

SI defaults are Pa for pressure, kg/mol for molar mass, K for temperature, and R = 8.314462618 J/(mol·K), giving density in kg/m³. For other systems pass a matching gas_constant and keep units consistent; the tool does not convert units for you.

Read the full KIT documentation →