ForHosting KIT · Science

Hydrate formula calculator

Work out how many water molecules a hydrate holds: 24.96 g of hydrate that dries to 15.96 g of salt with a molar mass of 159.6 g/mol gives n of 5, written MX·5H2O. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Anhydrous mass
15.96
Hydrate mass
24.96
Salt molar mass
159.6
Molar mass of water
18
You get
Water mass
9
Moles salt
0.1
Moles water
0.5
N
5

A hydrate formula calculator turns laboratory masses into the integer or near-integer n in MX·nH2O—the water of crystallization bound in a salt hydrate.

What water of crystallization means for salt hydrates

Many ionic solids crystallize from water with a fixed number of water molecules incorporated into the crystal lattice. The standard formula is written MX·nH2O, where MX is the anhydrous salt and n is the water of crystallization—the number of water molecules per formula unit. Experimentally, n is found by heating a weighed sample of the hydrate until the water is driven off, weighing the anhydrous residue, and comparing moles of water lost to moles of anhydrous salt remaining.

Because masses must share one unit and molar masses must match that unit (grams with g/mol, for example), the mole ratios cancel to a dimensionless n. Classroom problems often use copper(II) sulfate pentahydrate CuSO4·5H2O or barium chloride dihydrate BaCl2·2H2O, where careful data yield n near five or two after rounding. This calculator implements that gravimetric closed formula only: it does not look up tabulated hydrates, does not parse chemical formulas, and does not correct for incomplete drying or adsorbed surface water.

When salt molar mass is zero or non-positive the moles of salt are undefined, so the tool rejects the input rather than inventing a hydrate coefficient for a meaningless division.

Practical tips, limits, and related searches

Keep both masses in the same unit and pair them with molar masses in matching g/mol (or kg/mol) before you call the tool; mixing grams of sample with a molar mass written in kg/mol will scale n by a thousand without any warning from pure arithmetic. 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 both masses and the anhydrous molar mass and only need n; if your source is a word problem with only percentages, convert to masses first. Round-trip checks are easy: recompute water mass, moles of salt, moles of water, and their ratio by hand and confirm they equal the published fields within the same twelve-decimal rounding.

Homework checks for hydrate formulas

Students enter anhydrous and hydrate masses with the salt molar mass from textbook gravimetric problems and compare hand-written n against a deterministic result before submitting.

Lab verification of known hydrates

Technicians confirm that a dried batch matches the expected water of crystallization (for example n ≈ 5 for copper sulfate pentahydrate) without opening a spreadsheet for each check.

What is water of crystallization?

It is the number n of water molecules bound per formula unit in a salt hydrate MX·nH2O. Gravimetrically, n = (moles of water lost) / (moles of anhydrous salt remaining).

What happens when salt molar mass is zero?

Moles of salt are undefined when M_salt is zero.

Do I need to supply the molar mass of water?

Override it only if your course or standard uses a different value such as 18.0.

Why is my n not an integer?

Experimental scatter, incomplete drying, or rounded molar masses often leave n slightly off an integer.

Is the hydrate formula calculator free?

The browser tool is free and runs locally.

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.

POSThttps://api.kit.forhosting.com/chem/hydrate-formula

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.

curl -X POST https://api.kit.forhosting.com/chem/hydrate-formula \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"anhydrous_mass":15.96,"hydrate_mass":24.96,"salt_molar_mass":159.6}'
{
  "anhydrous_mass": 15.96,
  "hydrate_mass": 24.96,
  "salt_molar_mass": 159.6
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "chem.hydrate_formula",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs1000000000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Enter the mass of the anhydrous salt after gentle heating, the mass of the original hydrate, and the molar mass of the anhydrous salt; the tool subtracts to get water mass, converts both masses to moles using the salt molar mass and the molar mass of water (default 18.01528 g/mol), and returns n equals moles of water divided by moles of salt, plus a readable formula string, nearest integer n_rounded, and step-by-step substitution. When salt molar mass is zero the ratio is undefined, so the API returns a clear invalid_input error instead of Infinity or a silent NaN.

What water of crystallization means for salt hydrates

The closed formula is n equals (m_water divided by M_water) divided by (m_salt divided by M_salt), where m_water is hydrate mass minus anhydrous mass, M_salt is the molar mass of the anhydrous salt, and M_water is the molar mass of water.

How to call the API and what comes back

Anhydrous mass must be strictly positive; hydrate mass must be strictly greater than anhydrous mass so water mass is positive; salt molar mass and water molar mass must be strictly positive—values at or below one times ten to the minus fifteen, or any non-positive molar mass, are treated as zero and rejected. Send a JSON body with three required finite numbers: anhydrous_mass (aliases mass_anhydrous, m_anhydrous, m_salt, anhydrous, salt_mass), hydrate_mass (aliases mass_hydrate, m_hydrate, hydrate, hydrated_mass), and salt_molar_mass (aliases M_salt, molar_mass_salt, anhydrous_molar_mass, M_anhydrous, molar_mass). Optionally include water_molar_mass (aliases M_water, molar_mass_water, water_mm); when omitted the solver uses 18.01528 g/mol. Absolute values must stay within the published limit of one trillion so intermediate ratios remain finite in IEEE double precision on the Worker and in the browser. On success the response echoes rounded anhydrous_mass, hydrate_mass, water_mass, salt_molar_mass, and water_molar_mass, sets moles_salt and moles_water, n to the rounded ratio, n_rounded to the nearest integer, hydrate_formula to a string such as MX·5H2O when n is near an integer, formula to n equals m_water over M_water over m_salt over M_salt, unit to H2O per formula unit, message to a short English summary, and steps to an ordered array of substitution lines. Failed validation—missing fields, non-finite numbers, values outside absolute limits, zero salt molar mass, zero anhydrous mass, or hydrate mass not greater than anhydrous mass—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

For teaching, pair examples: fifteen point nine six grams anhydrous from twenty-four point nine six grams hydrate with M_salt one hundred fifty-nine point six and M_water eighteen yields n equals five; twenty point eight grams anhydrous from twenty-four point four grams hydrate with M_salt two hundred eight and M_water eighteen yields n equals two; and salt molar mass zero demonstrates the hard invalid_input path that protects division by zero. When experimental scatter leaves n at three point one or four point nine, n_rounded still supplies the textbook integer while n keeps the exact ratio for lab notebooks. This landing targets people searching for a hydrate formula calculator, water of crystallization calculator, or nH2O from mass online; it is not a chemical formula parser, not a percent composition by element tool, and not a density converter. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately set salt molar mass to zero.

Unit tests for stoichiometry software

Generate known-good n values plus deliberate zero salt-molar-mass rejections for coding kata and API contract tests.

Read the full KIT documentation →