Mass to gas volume calculator
32 g of oxygen at 1 atm and 273.15 K fill about 22.4 L, one mole of gas. Enter a gas mass, its molar mass, the pressure and the temperature in kelvin to get the volume in litres. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Mass
- 32
- Molar mass
- 32
- Pressure
- 1
- Creativity
- 273.15
- R
- 0.08205746 L
- Moles
- 1
- Volume
- 22.413995199
- Precision
- 10
This mass to gas volume calculator turns a known gas sample mass into the volume that sample occupies under a stated pressure and absolute temperature, using the ideal gas law. You supply the mass in grams, the molar mass in grams per mole, the pressure in atmospheres, and the temperature in kelvin; the engine returns the volume in litres together with the intermediate mole count. The governing identity is fully deterministic: volume equals mass times the gas constant times temperature, all divided by the product of molar mass and pressure. A classic check is thirty-two grams of oxygen at one atmosphere and two hundred seventy-three point one five kelvin, which is about one mole and therefore about twenty-two point four litres. The path uses only finite arithmetic with no network calls, no sampling, and no date-dependent shortcuts.
How mass, molar mass, P, and T are read and how V stays reproducible
Optional leading plus signs and scientific notation on numeric strings are allowed when they parse as finite decimals; embedded spaces, hex prefixes, and non-numeric tokens are rejected with a clear message so a bad cell does not become a wrong volume. Mass may be zero, which correctly yields zero volume and zero moles; negative mass is rejected as non-physical.
Molar mass and temperature must be strictly positive: zero or negative M would divide by zero or invent a non-physical species, and absolute temperature at or below zero kelvin is not allowed for the ideal-gas model here. Pressure must be non-zero so the division in V equals mRT over MP is defined.
Where gas volume from mass fits in study, lab, and software
Students meet mass-to-volume problems when a textbook gives grams of a pure gas and asks for the container volume at stated P and T, when a lab report converts weighed product gas into litres for stoichiometry checks, or when a process estimate needs the space a known mass of cylinder gas will occupy after expansion. Teachers can pre-generate answer keys for oxygen, nitrogen, carbon dioxide, and other common molar masses without trusting opaque calculator apps that silently switch between Celsius and kelvin or mix bar with atmospheres.
Developers call the same contract from scripts to seed deterministic test vectors for gas-handling UIs, to normalize user-entered masses before sizing vessels, or to satisfy programming-challenge statements that demand volume rather than a hand-waved STP rule of thumb. Contest practice often needs a fast, offline source of ideal-gas volumes so solutions can be checked without programmable calculators under time pressure. Product and education tools use the conversion when a learner types mass and conditions and the UI must show both moles and litres.
What you can do with it
Homework and lab volume checks
Convert textbook or lab gas masses into litres at given P and T, and verify moles before stoichiometry or vessel sizing.
Process and tutoring software
Normalize user-entered mass, M, P, and T into volume for demos, vessel calculators, and interactive gas-law lessons.
FAQ
What does the mass to gas volume calculator cost?
It is free in your browser on this page.
How is volume defined?
For mass m, molar mass M, pressure P, and temperature T, volume V = m·R·T/(M·P). With default units (g, g/mol, atm, K, R in L·atm/(mol·K)), V is in litres.
What happens if molar mass or temperature is zero or negative?
Molar mass and absolute temperature must be positive for a physical ideal-gas volume.
Does this tool assume STP or NTP automatically?
No. You always supply pressure and temperature. Use a dedicated STP or NTP volume tool if you only need the fixed-condition shortcut.
Why are results rounded to a precision?
Default precision is 10 decimal places; you can set precision from 0 to 15.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/chem/mass-to-gas-volume \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mass":32,"molar_mass":32,"pressure":1,"temperature":273.15}'const res = await fetch("https://api.kit.forhosting.com/chem/mass-to-gas-volume", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mass": 32,
"molar_mass": 32,
"pressure": 1,
"temperature": 273.15
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/chem/mass-to-gas-volume",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mass": 32,
"molar_mass": 32,
"pressure": 1,
"temperature": 273.15
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/chem/mass-to-gas-volume", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mass":32,"molar_mass":32,"pressure":1,"temperature":273.15}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mass":32,"molar_mass":32,"pressure":1,"temperature":273.15}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/chem/mass-to-gas-volume", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"mass": 32,
"molar_mass": 32,
"pressure": 1,
"temperature": 273.15
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "chem.mass_to_gas_volume",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_abs_value | 1000000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
What mass-to-volume means and what the response contains
Mass-to-gas-volume conversion answers a practical lab and process question: given how much gas you have by mass, what volume does it fill at the pressure and temperature of interest. The ideal gas law states that pressure times volume equals moles times the gas constant times absolute temperature. Moles are mass divided by molar mass, so substituting produces volume equals mass times R times T over M times P. This calculator returns the normalized mass, molar mass, pressure, temperature, and gas constant, the computed moles, the volume in litres rounded to the requested precision, the method tag mass_to_gas_volume, a short formula string, and the unit label L. There is no approximate equation-of-state table lookup and no random sampling of compressibility factors: the engine either builds exact floating-point volume inside the supported numeric range or rejects the input with invalid_input. Rejected cases include missing required fields, non-finite values, magnitudes above the documented ceiling, non-positive molar mass, non-positive temperature in kelvin, and zero pressure, because those make volume undefined or non-physical in this model.
How mass, molar mass, P, and T are read and how V stays reproducible
The preferred fields are mass for the sample mass in grams, molar_mass for M in grams per mole, pressure for P in atmospheres, and temperature for absolute T in kelvin, but aliases such as m and gas_mass for mass, M and molecular_weight for molar mass, P and atm for pressure, and T and kelvin for temperature are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. An optional R field, with aliases gas_constant and R_gas, overrides the default zero point zero eight two zero five seven four six litre-atmosphere per mole-kelvin when you intentionally use a different consistent constant; optional precision, with aliases decimals and dp, chooses how many decimal places to expose, defaulting to ten and capped at fifteen so JSON goldens stay stable.
Where gas volume from mass fits in study, lab, and software
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with molar-mass-from-density or STP-only volume tools when you need related gas steps, and with other chemistry endpoints when you are building a small lab of free, deterministic helpers.
Integration use cases
Deterministic test fixtures
Generate reproducible volume and moles fields for unit tests, property checks, and CI assertions on ideal-gas helpers.