ForHosting KIT · Science

Formula units calculator

Turn grams of a salt into a count of formula units: 58.44 g of sodium chloride at 58.44 g/mol is exactly one mole, or 6.02214076 × 10²³ formula units. The moles are shown too. 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
Sample mass in grams
58.44
Molar mass
58.44
You get
Moles
1
Formula units
602,214,076,000,000,000,000,000
Avogadro number
602,214,076,000,000,000,000,000
Precision
10

This formula units calculator converts a weighed sample of an ionic compound into a count of formula units using mass, molar mass, and the exact SI Avogadro constant. You supply the sample mass m in grams and the molar mass M in grams per mole; the engine first forms moles as m divided by M, then multiplies by Avogadro number to obtain N equals (m over M) times N_A, where N_A is six point zero two two one four zero seven six times ten to the twenty-three entities per mole. That constant has been fixed by definition since the twenty nineteen SI redefinition, so the conversion is pure arithmetic rather than a measured estimate. Textbook checks include one mole of sodium chloride at fifty eight point four four grams yielding Avogadro number of formula units, twice that mass yielding two moles and twice that count, and a zero mass yielding zero formula units. Zero or negative molar mass is rejected because division by zero is undefined and a non-positive M is not physically meaningful for this step. The path uses only finite arithmetic with no network calls, no sampling, and no date-dependent shortcuts.

What a formula unit count tells you

A formula unit is the smallest electrically neutral collection of ions that matches the empirical formula of an ionic compound, such as one sodium ion paired with one chloride ion for NaCl, or one calcium ion with two chloride ions for CaCl2. Unlike discrete covalent molecules, ionic solids do not exist as independent molecules; chemists still count the lattice in formula-unit multiples of the empirical formula.

Converting a laboratory mass into that count is a two-step bridge: divide mass by molar mass to obtain moles of formula units, then multiply by Avogadro number so one mole becomes exactly six point zero two two one four zero seven six times ten to the twenty-three formula units.

This calculator implements that identity with the fixed SI constant, so fifty eight point four four grams of sodium chloride at the usual molar mass of fifty eight point four four grams per mole is exactly one mole and therefore exactly Avogadro number of formula units.

Where formula-unit counts fit in study, lab work, and software

Students meet this conversion when a textbook asks how many formula units sit in a weighed sample of an ionic solid, when a contest problem gives grams and molar mass instead of a particle count, or when they bridge laboratory mass and microscopic counting before balancing equations or computing limiting reagents. Teachers can pre-generate answer keys for NaCl, KBr, MgO, and similar salts without trusting opaque calculator apps that round Avogadro inconsistently or switch scientific notation mid-step.

Lab courses often ask learners to interpret a balance reading as formula units before discussing lattice energy or dissolution, and a deterministic page removes calculator-brand variance from that step. Developers call the same contract from scripts to seed deterministic test vectors for stoichiometry engines, to normalize user-entered mass and molar mass before concentration demos, or to satisfy programming-challenge statements that demand a formula-unit count rather than a hand-waved scientific-notation guess.

Product and education tools use the conversion when a learner types grams and molar mass and the UI must show moles, formula units, and the constant used.

Homework and ionic-solid drills

Convert textbook mass and molar mass of salts into formula-unit counts with the fixed SI N_A and check answers before stoichiometry steps.

Lab prep and tutoring software

Normalize user-entered sample mass and molar mass into moles and formula units for worksheets, interactive lessons, and lab prep.

What does the formula units calculator cost?

It is free in your browser on this page.

What happens if molar mass is zero or negative?

Zero would divide by zero; a negative molar mass is not physical for this conversion.

Does this tool parse a chemical formula to get molar mass?

No. You supply mass and molar mass directly. Use a molar-mass or percent-composition tool if you need values from a formula string.

Why are mass and moles rounded to a precision?

Default precision is 10 decimal places; you can set precision from 0 to 15. The formula-unit count keeps full floating-point magnitude.

What is the difference between a formula unit and a molecule?

Ionic solids such as sodium chloride do not exist as separate molecules, so chemists count them in formula units instead: the smallest neutral group of ions that matches the formula, like one sodium and one chloride ion, or one calcium and two chloride ions in CaCl2.

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/formula-units

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/formula-units \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mass":58.44,"molar_mass":58.44}'
{
  "mass": 58.44,
  "molar_mass": 58.44
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "chem.formula_units",
  "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_abs_value1e+30
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.

What formula units mean and what the response contains

The response returns the normalized mass and molar mass, the intermediate moles value, the formula-unit count, the Avogadro number used, the precision applied, a method tag formula_units, a short formula string, and the unit label formula units. There is no approximate table lookup for molar mass from a chemical formula, no network call for constants, and no random sampling: the engine either builds a finite count inside the supported magnitude range or rejects the input with invalid_input. Rejected cases include a missing mass or molar_mass field, non-finite values such as Infinity or NaN, magnitudes above the documented ceiling, a negative mass, and any molar mass that is zero or negative, because those cases make N equals (m over M) times N_A undefined or non-physical.

How mass and molar mass are read and how counts stay reproducible

Optional leading plus signs and scientific notation on numeric strings are allowed when they parse as finite decimals; embedded spaces, hex prefixes, and non-numeric tokens are rejected with a clear message so a bad cell does not become a wrong formula-unit count. Zero mass is valid and simply yields zero moles and zero formula units. The preferred fields are mass for the sample mass in grams and molar_mass for the compound molar mass in grams per mole, but aliases m, grams, and mass_g for mass, and M, mm, molecular_weight, and MW for molar mass are accepted so spreadsheets, query strings, and typed forms can reuse the same contract without renaming columns. A negative mass, including negative zero, fails with invalid_input and a message that mentions the mass field. Molar mass must be strictly positive: zero, negative zero, or a value at or below a tiny epsilon fails with invalid_input because dividing by zero is undefined and a non-positive M is not a valid molar mass for this conversion. An optional precision field, with aliases decimals and dp, chooses how many decimal places to expose for the rounded mass, molar mass, and moles fields, defaulting to ten and capped at fifteen so JSON goldens stay stable; the formula-unit count is returned at full floating-point fidelity because it is typically a large scientific-notation magnitude. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the two-step conversion yourself.

Where formula-unit counts fit in study, lab work, and software

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with particles-to-moles, mass-to-mass stoichiometry, or molarity tools when you need related chemistry steps, and with other chem endpoints when you are building a small lab of free, deterministic helpers.

Deterministic test fixtures

Generate reproducible formula-unit values for unit tests, property checks, and CI assertions on chemistry engines.

How are formula units computed?

First moles n = m / M from mass and molar mass, then N = n · N_A with the exact SI constant N_A = 6.02214076×10²³ mol⁻¹.

Read the full KIT documentation →