Molar ratio calculator
36 g of water and 32 g of oxygen look alike on a balance, yet they stand in a 2:1 mole ratio. Enter both masses and molar masses to get the two mole amounts, the decimal ratio and the reduced pair. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Mass a
- 36
- Molar mass a
- 18
- Mass b
- 32
- Molar mass b
- 32
- Moles a
- 2
- Moles b
- 1
- Molar ratio
- 2
- Simplified a
- 2
Two laboratory masses do not tell you how two substances stand in a chemical recipe until you convert each mass into moles. The molar ratio of substance A to substance B is n_A divided by n_B, and each amount of substance follows from n equals mass over molar mass. This calculator takes the mass and molar mass of both substances, returns the two mole amounts, the decimal mole ratio, and a reduced integer pair such as 2:1 when the amounts share a common factor.
What a molar ratio is and how masses become moles
The molar ratio of two substances is the ratio of their amounts of substance, not the ratio of their masses. Mass ratios mislead whenever the two formula weights differ: thirty-six grams of water and thirty-two grams of oxygen look similar on a balance, but they stand in a two-to-one mole ratio because water's molar mass is about eighteen grams per mole and oxygen's is thirty-two. The integer pair two to one is the same information after cancelling a common factor, which is what lab notebooks and exam answers usually print.
This calculator does that conversion for any pair of finite masses and strictly positive molar masses. Zero mass of A is allowed and yields a zero ratio against a positive amount of B. Zero mass of B makes n_B zero, so the quotient is undefined and is rejected rather than billed as a successful infinity.
Where a mass-based molar ratio calculator earns its keep
Secondary-school and introductory university chemistry courses assign molar-ratio drills that convert two weighings into the mole ratio that belongs in a mole-to-mole table before a balanced equation is even used; a single trusted oracle speeds grading and demo setup without hand-waving floating-point noise. That classroom query is a different search from converting already-known moles with stoichiometric coefficients, which is a separate landing and must not cannibalize this page.
Analytical labs compare two solids when a protocol lists grams of each reagent and the chemist needs n_A over n_B before mixing stock. Process chemists and chemical engineers check whether a drum of A and a drum of B sit near a target mole ratio without converting units by hand in a spreadsheet.
If you later need moles from a single mass, mole fraction of a mixture, molality, molarity, empirical formulas from elemental masses, or product moles from a balanced equation, treat those as separate search intents and landings rather than overloading this molar ratio calculator.
What you can do with it
Homework mole-ratio tables from two weighings
Convert two sample masses and their molar masses into n_A : n_B so students and auto-graders share one closed-form ground truth before any balanced equation is applied.
Two-reagent prep from weighed solids
Turn grams of two pure solids into a mole ratio before dissolving or mixing, so the recipe matches the intended n_A per mole of B.
Batch inventory mole-ratio checks
Estimate how two reagent drums stand in moles from known bottle masses and formula weights, without a spreadsheet of hidden unit conversions.
FAQ
What happens if a molar mass is zero or negative?
Any molar mass that is not a positive number makes n = m / M undefined or non-physical and is rejected instead of returning Infinity or NaN.
What units should I use for mass and molar mass?
Masses are grams (g) and molar masses are grams per mole (g/mol). Convert milligrams to grams by dividing by 1000 (or kilograms by multiplying by 1000) before calling so the quotients remain moles.
How is this different from a stoichiometric mole-ratio calculator?
This page starts from two masses and two molar masses. A stoichiometric mole-ratio tool starts from already-known moles and balanced-equation coefficients. They answer different search queries and keep separate landings.
What does the molar ratio calculator cost?
The browser tool is free and runs locally.
Why is the mole ratio different from the mass ratio?
Because each substance has its own molar mass. Water weighs about 18 g/mol and oxygen 32 g/mol, so 36 g of water is 2 mol while 32 g of oxygen is only 1 mol.
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/molar-ratio \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mass_a":36,"molar_mass_a":18,"mass_b":32,"molar_mass_b":32}'const res = await fetch("https://api.kit.forhosting.com/chem/molar-ratio", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mass_a": 36,
"molar_mass_a": 18,
"mass_b": 32,
"molar_mass_b": 32
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/chem/molar-ratio",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mass_a": 36,
"molar_mass_a": 18,
"mass_b": 32,
"molar_mass_b": 32
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/chem/molar-ratio", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mass_a":36,"molar_mass_a":18,"mass_b":32,"molar_mass_b":32}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mass_a":36,"molar_mass_a":18,"mass_b":32,"molar_mass_b":32}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/chem/molar-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
{
"mass_a": 36,
"molar_mass_a": 18,
"mass_b": 32,
"molar_mass_b": 32
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "chem.molar_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. |
Technical notes
Any molar mass that is not a positive number is rejected with invalid_input, so a zero or negative denominator never becomes Infinity.
What a molar ratio is and how masses become moles
Convert each mass with n equals m over M, then divide the two mole amounts: molar_ratio equals n_A over n_B. A molar mass that is zero, negative, infinite, or missing is not a positive number, so the task fails with invalid_input instead of returning Infinity or a silent NaN. The implementation is a handful of divisions in deterministic floating-point arithmetic: no random seeds, no wall-clock timestamps, no network calls, and no model drift, so identical inputs always produce identical JSON. It does not look up molar masses from chemical formulas, apply stoichiometric coefficients from a balanced equation, convert milligrams for you, or compute mole fraction, molality, or molarity; those are separate search intents with their own landings when product coverage grows.
Input contract, response shape, and error behaviour
Masses are in grams and must be greater than or equal to zero. Wire the free browser form for homework and quick sanity checks, then call the identical contract from scripts when you need bulk answer keys or grading oracles. Keep both masses on the gram scale across multi-step lab pipelines: if you weigh in milligrams, convert first so the numeric ratio still matches the mole ratio your report claims. Send four required finite numbers: mass_a and molar_mass_a for substance A, and mass_b and molar_mass_b for substance B. Molar masses are in grams per mole and must be strictly greater than zero; zero or negative values fail with invalid_input because they are not positive numbers and would make n equals m over M undefined or non-physical. Missing fields, empty strings, non-numeric values, NaN, and Infinity fail with invalid_input naming the field and are not charged. On success the response echoes the four cleaned inputs, reports moles_a and moles_b in moles, reports molar_ratio as n_A divided by n_B (moles of A per mole of B), and when the two amounts share a small integer factor it also reports simplified_a, simplified_b, and a ratio_string such as 2:1. A units hint object, a method key, and a formula string travel with the numbers so homework write-ups and API clients can cite the same closed form. Classic textbook checks include thirty-six grams at eighteen grams per mole versus thirty-two grams at thirty-two grams per mole, which yields two moles of A, one mole of B, molar_ratio two, and the reduced pair 2:1, and ten grams at forty grams per mole versus thirty-six point five grams at thirty-six point five grams per mole, which yields one-to-four after reduction. Pricing for successful API calls is the published $0.002 per item; validation failures do not consume prepaid balance.
Where a mass-based molar ratio calculator earns its keep
Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance. Pin the cleaned JSON in tests, keep both molar masses strictly positive, and you get a reproducible mole ratio for homework, LIMS plugins, and edge workers without standing up computer-algebra infrastructure of your own.
Technical questions
How do I compute the molar ratio of two substances from their masses?
Convert each mass to moles with n = m / M, then divide: molar_ratio = n_A / n_B. Send mass_a, molar_mass_a, mass_b, and molar_mass_b in grams and g/mol. The API also returns a reduced integer pair such as 2:1 when the amounts share a small common factor.