The Ideal Gas Law is a fundamental equation in chemistry and physics that describes the behavior of an ideal gas. An ideal gas is a theoretical gas composed of many randomly moving point particles that are not subject to interparticle attractive forces. While no real gas is perfectly ideal, many gases behave approximately ideally under common conditions (e.g., at high temperatures and low pressures).
The Formula: PV = nRT
The Ideal Gas Law is expressed by the equation:
PV = nRT
Where:
P = Pressure of the gas
V = Volume occupied by the gas
n = Number of moles of the gas (amount of substance)
R = Ideal Gas Constant (a proportionality constant)
T = Absolute Temperature of the gas
Key Concepts and Units
Pressure (P): Measured in units like atmospheres (atm), kilopascals (kPa), Pascals (Pa), pounds per square inch (psi), or bar. It represents the force exerted by the gas particles per unit area.
Volume (V): Measured in units like liters (L), cubic meters (m³), milliliters (mL), or cubic centimeters (cm³). It is the space occupied by the gas.
Moles (n): A unit of amount of substance, representing approximately 6.022 x 10²³ particles (Avogadro's number).
Ideal Gas Constant (R): The value of R depends on the units used for pressure and volume. Common values include 0.08206 L·atm/(mol·K) or 8.314 J/(mol·K) (which is equivalent to m³·Pa/(mol·K)). Our calculator uses a consistent set of SI units for internal calculations to ensure accuracy.
Temperature (T): Must always be in absolute temperature units, typically Kelvin (K). If you input Celsius (°C) or Fahrenheit (°F), the calculator will automatically convert it to Kelvin for the calculation.
How to Use the Ideal Gas Law Calculator
This calculator allows you to determine any one of the four variables (Pressure, Volume, Moles, or Temperature) if you know the other three. Simply select the variable you wish to calculate, enter the known values with their respective units, and the calculator will provide the result.
Example Scenarios:
Calculating Pressure: Imagine you have 2.5 moles of a gas occupying a volume of 10.0 L at a temperature of 300 K. What is the pressure?
Calculating Volume: A gas at 2.0 atm pressure and 298 K contains 0.75 moles. What volume does it occupy?
Calculating Moles: If a gas occupies 5.0 L at 1.5 atm and 273 K, how many moles of gas are present?
Calculating Temperature: A sample of gas with 1.2 moles is at 3.0 atm pressure and occupies 8.0 L. What is its temperature in Kelvin?
The Ideal Gas Law is a powerful tool for understanding and predicting the behavior of gases in various scientific and engineering applications.
Ideal Gas Law Calculator (PV=nRT)
Calculate Pressure (P), Volume (V), Moles (n), or Temperature (T) using the Ideal Gas Law.
Pressure (P)
Volume (V)
Moles (n)
Temperature (T)
atm
kPa
Pa
psi
bar
mmHg
L
m³
mL
cm³
mol
K
°C
°F
.calculator-container {
background-color: #f9f9f9;
border: 1px solid #ddd;
padding: 20px;
border-radius: 8px;
max-width: 600px;
margin: 20px auto;
font-family: Arial, sans-serif;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.calc-input-group {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.calc-input-group label {
flex: 2;
margin-right: 10px;
color: #555;
}
.calc-input-group input[type="number"] {
flex: 3;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
margin-right: 10px;
}
.calc-input-group select {
flex: 1;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
.calc-input-group .unit-display {
flex: 1;
padding: 8px;
text-align: left;
color: #555;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
margin-top: 20px;
}
button:hover {
background-color: #0056b3;
}
.calc-result {
margin-top: 20px;
padding: 15px;
border: 1px solid #e0e0e0;
border-radius: 4px;
background-color: #e9ecef;
color: #333;
font-size: 1.1em;
text-align: center;
}
.calculator-article {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 600px;
margin: 20px auto;
padding: 0 15px;
}
.calculator-article h2,
.calculator-article h3 {
color: #007bff;
margin-top: 25px;
margin-bottom: 15px;
}
.calculator-article ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 15px;
}
.calculator-article ol {
list-style-type: decimal;
margin-left: 20px;
margin-bottom: 15px;
}
.calculator-article li {
margin-bottom: 5px;
}
.calculator-article code {
background-color: #e9ecef;
padding: 2px 4px;
border-radius: 3px;
font-family: 'Courier New', Courier, monospace;
}
function toggleInputs() {
var solveFor = document.getElementById('solveFor').value;
document.getElementById('pressureValue').disabled = false;
document.getElementById('pressureUnit').disabled = false;
document.getElementById('volumeValue').disabled = false;
document.getElementById('volumeUnit').disabled = false;
document.getElementById('molesValue').disabled = false;
document.getElementById('temperatureValue').disabled = false;
document.getElementById('temperatureUnit').disabled = false;
if (solveFor === 'P') {
document.getElementById('pressureValue').disabled = true;
document.getElementById('pressureUnit').disabled = true;
} else if (solveFor === 'V') {
document.getElementById('volumeValue').disabled = true;
document.getElementById('volumeUnit').disabled = true;
} else if (solveFor === 'n') {
document.getElementById('molesValue').disabled = true;
} else if (solveFor === 'T') {
document.getElementById('temperatureValue').disabled = true;
document.getElementById('temperatureUnit').disabled = true;
}
}
window.onload = toggleInputs;
function calculateIdealGasLaw() {
var solveFor = document.getElementById('solveFor').value;
var pressureValue = parseFloat(document.getElementById('pressureValue').value);
var pressureUnit = document.getElementById('pressureUnit').value;
var volumeValue = parseFloat(document.getElementById('volumeValue').value);
var volumeUnit = document.getElementById('volumeUnit').value;
var molesValue = parseFloat(document.getElementById('molesValue').value);
var temperatureValue = parseFloat(document.getElementById('temperatureValue').value);
var temperatureUnit = document.getElementById('temperatureUnit').value;
var R_SI = 8.314462618;
var inputsValid = true;
var missingInputs = [];
if (solveFor !== 'P' && (isNaN(pressureValue) || pressureValue < 0)) { inputsValid = false; missingInputs.push('Pressure (must be non-negative)'); }
if (solveFor !== 'V' && (isNaN(volumeValue) || volumeValue < 0)) { inputsValid = false; missingInputs.push('Volume (must be non-negative)'); }
if (solveFor !== 'n' && (isNaN(molesValue) || molesValue < 0)) { inputsValid = false; missingInputs.push('Moles (must be non-negative)'); }
if (solveFor !== 'T' && isNaN(temperatureValue)) { inputsValid = false; missingInputs.push('Temperature'); }
if (!inputsValid) {
document.getElementById('result').innerHTML = 'Please enter valid non-negative numbers for all known variables: ' + missingInputs.join(', ') + '.';
return;
}
var P_Pa, V_m3, T_K;
if (solveFor !== 'P') {
switch (pressureUnit) {
case 'atm': P_Pa = pressureValue * 101325; break;
case 'kPa': P_Pa = pressureValue * 1000; break;
case 'Pa': P_Pa = pressureValue; break;
case 'psi': P_Pa = pressureValue * 6894.76; break;
case 'bar': P_Pa = pressureValue * 100000; break;
case 'mmHg': P_Pa = pressureValue * 133.322; break;
default: P_Pa = pressureValue;
}
}
if (solveFor !== 'V') {
switch (volumeUnit) {
case 'L': V_m3 = volumeValue * 0.001; break;
case 'm3': V_m3 = volumeValue; break;
case 'mL': V_m3 = volumeValue * 1e-6; break;
case 'cm3': V_m3 = volumeValue * 1e-6; break;
default: V_m3 = volumeValue;
}
}
if (solveFor !== 'T') {
switch (temperatureUnit) {
case 'K': T_K = temperatureValue; break;
case 'C': T_K = temperatureValue + 273.15; break;
case 'F': T_K = (temperatureValue – 32) * 5/9 + 273.15; break;
default: T_K = temperatureValue;
}
if (T_K <= 0) {
document.getElementById('result').innerHTML = 'Temperature must be above absolute zero (0 K).';
return;
}
}
var resultValue;
var resultUnit;
if (solveFor === 'P') {
if (V_m3 === 0) {
document.getElementById('result').innerHTML = 'Volume cannot be zero when calculating Pressure.';
return;
}
resultValue = (molesValue * R_SI * T_K) / V_m3;
resultValue = resultValue / 101325;
resultUnit = 'atm';
} else if (solveFor === 'V') {
if (P_Pa === 0) {
document.getElementById('result').innerHTML = 'Pressure cannot be zero when calculating Volume.';
return;
}
resultValue = (molesValue * R_SI * T_K) / P_Pa;
resultValue = resultValue / 0.001;
resultUnit = 'L';
} else if (solveFor === 'n') {
if (T_K === 0) {
document.getElementById('result').innerHTML = 'Temperature cannot be zero when calculating Moles.';
return;
}
resultValue = (P_Pa * V_m3) / (R_SI * T_K);
resultUnit = 'mol';
} else if (solveFor === 'T') {
if (molesValue === 0) {
document.getElementById('result').innerHTML = 'Moles cannot be zero when calculating Temperature.';
return;
}
resultValue = (P_Pa * V_m3) / (molesValue * R_SI);
resultUnit = 'K';
}
document.getElementById('result').innerHTML = '