Ideal gas law calculator
One mole at 101325 Pa filling 0.0224 m³ sits just below 273.15 K. Give any three of pressure, volume, amount of gas and temperature, and the ideal gas law returns the fourth with each step written out. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Power (W)
- 101,325
- Voltage (V)
- 0.0224
- N
- 1
- Pressure
- 101,325
- Volume
- 0.0224
- Moles
- 1
- T
- 272.9797587984
An ideal gas law calculator rearranges PV equals nRT so you can solve for whichever state variable you do not already know. Pressure, volume, moles, and the gas constant must also be positive so the rearrange never divides by zero or invents a non-physical magnitude. The default gas constant is the SI value 8.314462618 joules per mole per kelvin, matching pascals and cubic metres; pass your own R when you work in litres and atmospheres or other consistent units. Lab prep, exam checks, and coding-kata expected values all need that same rearrange without opening a full equation-of-state suite.
What the ideal gas law means and when to use it
Real gases approach this model when pressure is not too high and temperature is not too low relative to the gas critical point, so introductory chemistry and physics problems almost always start here before adding van der Waals or other corrections.
Units of P, V, and R must match each other: with the default R of 8.314462618 joules per mole per kelvin, pressure is in pascals and volume in cubic metres; if you prefer atmospheres and litres, supply R approximately 0.082057 litres atmospheres per mole per kelvin instead of relying on the SI default. Exactly three of the four state variables must be known so the fourth is uniquely determined; providing all four or fewer than three is a validation error rather than a silent average or consistency residual.
The check path recomputes the rearranged expression with the same fixed rounding used for published fields, so a successful response always ships with steps you can assert in tests or worksheets.
Practical tips, limits, and related searches
Convert Celsius to kelvin before calling the tool, and never pass a temperature of zero or below on the absolute scale. Keep inputs inside the published absolute range so products such as n R T cannot overflow into a non-finite result that the solver must reject. Prefer sending numbers rather than pre-formatted strings when you control the client; string numbers are accepted only when they match a strict finite numeric pattern.
Prefer this capability when you already have three consistent state quantities and only need the fourth under the ideal-gas assumption; if your gas is dense or near condensation, use a real-gas model instead.
What you can do with it
Homework checks for PV = nRT
Students enter three known state variables from textbook ideal-gas problems and compare hand-written P, V, n, or T against a deterministic result before submitting.
Lab prep and process estimates
Quickly estimate the missing pressure, volume, moles, or temperature for a gas sample when the ideal-gas approximation is acceptable.
FAQ
What formula does the ideal gas law calculator use?
It rearranges PV = nRT. Depending on which variable you omit: P = nRT/V, V = nRT/P, n = PV/(RT), or T = PV/(nR).
What happens if temperature is zero or negative kelvin?
Non-positive absolute temperature is not valid for the ideal gas law.
Which gas constant R is used by default?
Default R is 8.314462618 J/(mol·K) for SI units (pressure in Pa, volume in m³). Pass your own r when using other consistent unit systems such as L·atm.
Can I send all four of P, V, n, and T?
No. Provide exactly three and omit the unknown.
Is the ideal gas law calculator free?
The browser tool is free and runs locally.
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/thermo/ideal-gas-law \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"p":101325,"pressure":-1000000000000}'const res = await fetch("https://api.kit.forhosting.com/thermo/ideal-gas-law", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"p": 101325,
"pressure": -1000000000000
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/thermo/ideal-gas-law",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"p": 101325,
"pressure": -1000000000000
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/thermo/ideal-gas-law", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"p":101325,"pressure":-1000000000000}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"p":101325,"pressure":-1000000000000}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/thermo/ideal-gas-law", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"p": 101325,
"pressure": -1000000000000
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "thermo.ideal_gas_law",
"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 | 1000000000000 |
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
Temperature must be strictly positive on the kelvin scale—zero or negative kelvin is rejected with a clear invalid_input error because absolute temperature cannot be non-positive in this model.
What the ideal gas law means and when to use it
The ideal gas law states that the product of pressure and volume equals the product of the amount of substance, the gas constant, and absolute temperature: P times V equals n times R times T. Absolute temperature must be in kelvin (or another absolute scale consistent with R); converting from Celsius means adding 273.15 before you call the API, because a non-positive kelvin value has no meaning for this equation and is rejected. Teachers and automated graders care about the non-positive temperature rejection as much as the success path: a learner who forgets the Celsius-to-kelvin shift should see an explicit invalid_input message instead of a nonsense negative absolute temperature.
How to call the API and what comes back
Every provided state variable and the gas constant must be strictly positive; temperature in particular must be positive kelvin whether it is an input or the solved unknown. Send a JSON body with exactly three of the four state fields filled: p (aliases pressure and P), v (aliases volume and V), n (aliases moles, amount, and mol), and t (aliases temperature, T, temp, and kelvin). Optionally include r (aliases R, gas_constant, and gasConstant); when omitted the solver uses 8.314462618. Absolute values must stay within the published limit of one trillion so intermediate products remain finite in IEEE double precision on the Worker and in the browser. On success the response echoes rounded p, v, n, t, and r, mirrors them as pressure, volume, moles, temperature, temperature_kelvin, and gas_constant, sets solved_for and unknown to the single letter of the omitted variable, formula and rearrange to the algebraic form used, equation to a filled PV equals nRT string, product_pv and product_nrt to the two sides after rounding, message to a short English summary, and steps to an ordered array of substitution lines. Failed validation—wrong count of state variables, missing numbers, non-finite values, values outside absolute limits, non-positive P V n R, or non-positive temperature in kelvin—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, limits, and related searches
When teaching, pair examples: omit temperature with roughly one atmosphere, twenty-two point four litres worth of cubic metres, and one mole to recover near two hundred seventy-three kelvin; omit pressure with the same volume, one mole, and two hundred seventy-three point fifteen kelvin to recover near standard pressure; omit volume or moles to practice the other two rearrangements; and deliberately send t equals zero to demonstrate the hard invalid_input path. This landing targets people searching for an ideal gas law calculator, PV equals nRT solver, or pressure-volume-moles-temperature online; it is not a real-gas equation-of-state tool, not a multi-component mixture calculator, and not a unit converter by itself. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately send bad temperatures. Round-trip checks are easy: recompute the rearranged expression by hand and confirm it equals the published unknown within the same twelve-decimal rounding, and confirm that product_pv and product_nrt agree for a fully consistent rounded state.
Integration use cases
Unit tests for student gas solvers
Generate known-good rearrangements for each unknown plus deliberate non-positive kelvin rejections for coding kata expected values.