Specific humidity to mixing ratio calculator
Specific humidity and water vapor mixing ratio describe the same moisture content with different reference masses.
Run — free
Specific humidity uses the total mass of moist air, while mixing ratio uses only the mass of dry air. This calculator converts either quantity into the other in kilograms per kilogram, reports both values, and identifies the equation used. It is useful for atmospheric observations, meteorological models, environmental datasets, and classroom calculations where the distinction between moist-air and dry-air denominators matters.
Understand what each humidity ratio measures
Specific humidity, commonly written as q, is the mass of water vapor divided by the total mass of moist air. That total includes both dry air and water vapor. Water vapor mixing ratio, commonly written as r, instead divides the vapor mass by the mass of dry air alone. Because its denominator is smaller, the mixing ratio is slightly larger than the corresponding specific humidity whenever moisture is present. Both quantities are dimensionless mass ratios, although they are often displayed as kilograms of water vapor per kilogram of air or as grams per kilogram. This calculator keeps the calculation in kg/kg so the algebra is explicit and no hidden unit scaling is introduced. Choose which quantity your value represents, enter the nonnegative ratio, and read the paired result. The distinction is small for ordinary atmospheric moisture levels, but treating the terms as interchangeable can introduce systematic errors in precise calculations, model initialization, or comparisons between datasets that use different conventions.
Apply the forward and reverse equations
To convert specific humidity to mixing ratio, the calculator uses r = q / (1 - q). The subtraction removes the vapor share from the total moist-air basis, leaving the dry-air basis required by r. This direction has an important mathematical boundary: q must be less than 1 kg/kg. At q = 1, the denominator is zero; above 1, the value cannot represent a physical mass fraction and the algebra would produce a misleading result. The calculator therefore returns an input error for every specific-humidity value at or above one. For the reverse conversion, it uses q = r / (1 + r). A nonnegative finite mixing ratio always produces a specific humidity from zero up to, but never reaching, one. Results are rounded only to a stable fifteen-significant-digit representation, retaining ample precision while avoiding distracting binary floating-point artifacts. The response also includes the formula selected, which makes automated results easier to audit and explain.
Use the result consistently in atmospheric work
Before converting, confirm the definition used by the source rather than relying on a column called simply humidity. Weather archives, radiosonde products, reanalysis files, and simulation outputs may use q for specific humidity, r or w for mixing ratio, and sometimes express either quantity in g/kg. If your source is in g/kg, divide by 1,000 before entering it here, then multiply the returned kg/kg value by 1,000 if you need a g/kg result. Keep mass-based ratios separate from relative humidity, which is a vapor-pressure comparison that also depends on temperature, and from absolute humidity, which is vapor mass per volume. The output is suitable for deterministic preprocessing, quality-control checks, scientific notebooks, and conversions at data-ingestion boundaries. For automated use, each request costs $0.002. Validate metadata and units upstream, preserve enough precision for the next calculation, and record whether the original variable used a moist-air or dry-air denominator so another analyst can reproduce the transformation.
What you can do with it
Normalize weather observations
Convert reported specific humidity into the dry-air mixing ratio expected by an atmospheric analysis workflow.
Prepare model input
Transform a mixing-ratio field into specific humidity before loading data into a model that uses moist-air mass fractions.
Check scientific calculations
Verify forward and reverse humidity conversions with the applied equation shown beside both values.
FAQ
What is the difference between specific humidity and mixing ratio?
Specific humidity divides vapor mass by total moist-air mass, while mixing ratio divides vapor mass by dry-air mass.
Why must specific humidity be less than 1 kg/kg?
It is a mass fraction of the total moist air. At one the forward equation divides by zero, and larger values are not valid mass fractions.
Can I enter a value in grams per kilogram?
The input is kg/kg. Divide g/kg by 1,000 before entering it, and multiply the kg/kg output by 1,000 to return to g/kg.
Is this the same as relative humidity?
No. Relative humidity compares vapor pressure with saturation vapor pressure and depends on temperature; these are mass ratios.
How much does an API calculation cost?
Each API request costs $0.002. The calculation is deterministic and does not call an external service.
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/earth/specific-humidity-to-mixing-ratio \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"value":0.012,"convert_from":"specific_humidity"}'const res = await fetch("https://api.kit.forhosting.com/earth/specific-humidity-to-mixing-ratio", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"value": 0.012,
"convert_from": "specific_humidity"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/earth/specific-humidity-to-mixing-ratio",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"value": 0.012,
"convert_from": "specific_humidity"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/earth/specific-humidity-to-mixing-ratio", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"value":0.012,"convert_from":"specific_humidity"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"value":0.012,"convert_from":"specific_humidity"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/earth/specific-humidity-to-mixing-ratio", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"value": 0.012,
"convert_from": "specific_humidity"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "earth.specific_humidity_to_mixing_ratio",
"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.
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. |