ForHosting KIT · Science

Ideal gas density calculator

Find how dense a gas is at the conditions you actually have: dry air at 101325 Pa and 298.15 K, with a molar mass of 0.02897 kg/mol, comes to about 1.2 kg/m³. Use your own gas constant for other units. 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.02897
Creativity
298.15
You get
Resistance (Ω)
8.314462618
Density
1.1841210699

Ideal-gas mass density follows directly from the equation of state once pressure, molar mass, and absolute temperature are known. Rearranging PV equals nRT into mass per volume yields rho equals P times M over R times T, the standard classroom and engineering shortcut for dry air, process gases, and homework checks under the ideal-gas assumption.

Ideal-gas density formula and how to choose inputs

Start from the ideal-gas law P V equals n R T. Mass m equals n times molar mass M, so density rho equals m over V equals n M over V. Substituting n over V equals P over R T produces the working identity rho equals P M over R T.

Pressure and molar mass must also be positive so the returned density is a meaningful positive mass density under the ideal-gas model. If you work in atmospheres and grams per litre, pass a matching R such as zero point zero eight two zero five seven and keep every field coherent—the engine does not convert units automatically.

Homework and exam verification

Students compute ideal-gas density from P, M, and T, compare against worked solutions near room conditions, and get a clear error when zero or negative kelvin is submitted by mistake.

Lab notebooks and process estimates

Digital notebooks and pilot-plant helpers estimate dry-gas density under the ideal-gas assumption for air, nitrogen, or other light gases without embedding a thermo database.

How do I calculate ideal gas density with this tool?

The response density is ρ = P·M/(R·T) using the default CODATA R unless you pass a custom r.

What happens if temperature is zero or negative?

Absolute temperature must be strictly positive; zero or negative kelvin is rejected and not charged.

Which units should I use?

Keep P, M, R, and T coherent. Default R is 8.314462618 J/(mol·K): use Pa and kg/mol for density in kg/m³, or pass another R for L·atm or other classroom unit systems.

Is the ideal gas density calculator free?

The browser tool runs free on your device.

Does this support real gases or compressibility factors?

No. This product implements only the ideal-gas density ρ=PM/RT. Real-gas equations of state are a different intent and are not included.

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/chem/gas-density-ideal

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/chem/gas-density-ideal \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pressure":101325,"molar_mass":0.02897,"temperature":298.15}'
{
  "pressure": 101325,
  "molar_mass": 0.02897,
  "temperature": 298.15
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "chem.gas_density_ideal",
  "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.

This capability evaluates that formula deterministically with a CODATA default gas constant, accepts a custom R when your unit system is not SI, rejects zero or negative kelvin with a clear invalid input error, and returns JSON that lab notebooks, tutoring apps, and lightweight process calculators can pin in tests without a thermo package.

Ideal-gas density formula and how to choose inputs

Send required fields pressure, molar_mass, and temperature as finite JSON numbers or numeric strings; aliases P, p, press for pressure, M, mm, molecular_weight, MW for molar mass, and T, t, temp for temperature are accepted. Absolute temperature must be strictly positive in kelvin: zero or negative values are invalid_input because the denominator would be non-physical or singular. Optional field r (aliases gas_constant, R) defaults to eight point three one four four six two six one eight joules per mole kelvin, the CODATA molar gas constant; with pressure in pascals and molar mass in kilograms per mole the density unit is kilograms per cubic metre. Identical inputs always produce identical JSON because the path is pure arithmetic with no network, no random seed, and no wall clock.

Reading the density response and validating physical sense

Use density alone when a dashboard only needs the scalar; use the echoed inputs when grading software must confirm that unit choices and R were not silently changed; use formula and method when audit logs need a human-readable identity. Typical dry-air checks near one atmosphere and room temperature land near one point two kilograms per cubic metre when SI inputs are used—if your result is orders of magnitude off, verify that M is in kilograms per mole rather than grams per mole, or that P is in pascals rather than bar or atmospheres without adjusting R. The formula label is always the Unicode string rho equals P M over R T, and method is always ideal_gas_density so downstream code can branch without sniffing shapes. Missing required fields, non-finite numbers, non-positive pressure or molar mass, custom R that is not positive, and temperature less than or equal to zero all fail with invalid_input and are not charged. Magnitude caps reject absurd scientific-notation extremes that would overflow a Worker isolate while still covering every classroom and pilot-scale process example.

API usage, pricing, lab workflows, and practical limits

Call the free in-browser ideal gas density calculator for homework checks, lecture demos, and quick sanity tests on HVAC or chem-lab estimates without installing a full process simulator. The ideal-gas model breaks down near condensation, at very high pressure, or for strongly non-ideal mixtures—those cases need a real-gas equation of state and are out of scope here by design. Authors shipping SDKs can map the density field straight into UI readouts while showing formula as a caption so students see the same rho equals P M over R T identity they write by hand. Send a JSON body with pressure, molar_mass, and temperature, and optionally r when you are not using SI. Use the prepaid API when a tutoring platform, digital lab notebook, SCADA helper, or curriculum generator needs a stable contract under KIT balance at $0.002 per successful item; validation failures never consume balance after the engine rejects the request. Pair this endpoint with partial-pressure or mole-fraction tools when you already know composition and total pressure, or with isothermal work calculators when the next step is expansion work at fixed temperature.

Tutoring and curriculum generators

Lesson builders produce stable JSON for density drills, flashcards, and auto-graded gas-law problems at $0.002 per successful API item.

Read the full KIT documentation →