ForHosting KIT · Science

Moles to grams calculator

18.015 grams of water with a molar mass of 18.015 g/mol is exactly 1 mole, and the same tool works backwards from moles to grams. Enter the molar mass plus either value and see each step of the calculation. 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
18.015
Molar mass
18.015
You get
Moles
1
Unit mass
g
Unit moles
mol
Unit molar mass
g/mol

A moles-to-grams calculator turns sample mass and molar mass into amount of substance, or converts moles back into grams with the same closed formulas every chemistry course teaches. Enter mass in grams and molar mass in grams per mole to get n equals m over M, or enter moles and molar mass to get m equals n times M. Lab prep, stoichiometry homework, exam checks, and automated graders all need that bidirectional conversion without a spreadsheet or a full chemical database.

What mass, moles, and molar mass mean together

Amount of substance in moles counts how many particles you have on the chemist's scale of Avogadro's number, while mass in grams is what a balance reports. Molar mass M links the two: it is the mass of one mole of a pure substance, usually tabulated in grams per mole from the molecular or formula weight. The defining relations are n equals m divided by M when you know the sample mass, and m equals n times M when you know the amount in moles.

Those identities are exact in SI once units are consistent—grams with grams per mole yield moles, and moles times grams per mole yield grams—so classroom problems and industrial batch sheets use the same algebra. Teachers and automated graders care about the zero-molar-mass rejection as much as the happy path: dividing by a blank or zero M is not a physical conversion, and a silent fallback would hide a data-entry error.

Water at about 18.015 grams per mole is the classic teaching example—eighteen grams is roughly one mole—while salts, metals, and polymers simply change M. The check path recomputes either n or m with the same fixed rounding used for published fields, so a successful response always ships with steps you can assert in tests or lab notebooks.

Practical tips, limits, and related searches

Keep masses, moles, and molar masses inside the published absolute range so n equals m over M and m equals n times M cannot overflow into a non-finite result the solver must reject. 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. Use grams and grams per mole consistently—if your source mass is in kilograms, convert before calling rather than mixing unit systems inside one request.

Prefer this capability when you already have mass or moles and a known M; if your source is only a formula string, resolve molar mass first. Round-trip checks are easy: convert mass to moles and multiply back by M to recover the original mass within the same twelve-decimal rounding, and confirm that changing only the direction flips the formula string between the two documented identities.

Lab prep mass from target moles

Technicians enter planned moles and tabulated molar mass to get the weigh-out mass in grams before starting a synthesis or titration.

Homework checks for n = m / M

Students convert textbook sample masses into moles and compare hand-written answers against a deterministic result before submitting.

How do you convert moles to grams?

Multiply amount in moles by molar mass in g/mol: m = n · M. This tool returns the mass in grams with fixed rounding and substitution steps.

How do you find moles from mass?

Divide sample mass in grams by molar mass in g/mol: n = m / M.

Is the moles to grams calculator free?

The browser tool is free and runs locally.

How many moles are in 18.015 grams of water?

One mole. Water has a molar mass of about 18.015 g/mol, so dividing 18.015 grams by 18.015 g/mol gives 1 mol, which is why water is the classic first example of turning mass into moles.

What happens if the molar mass is zero?

The calculator rejects it with a clear message instead of dividing by zero. Molar mass must be greater than zero, values so small that they count as zero are refused too, and mass or moles cannot be negative.

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/moles-from-mass

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/moles-from-mass \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"molar_mass":18.015}'
{
  "molar_mass": 18.015
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "chem.moles_from_mass",
  "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.

Zero or non-positive molar mass is rejected with a clear invalid_input error so a worksheet typo never silently divides by zero.

How to call the API and what comes back

Mass and moles must be non-negative; molar mass must be strictly positive—values at or below one times ten to the minus fifteen are treated as zero and rejected. Send a JSON body with required finite molar_mass (aliases M, molecular_weight, mw, molarMass) in grams per mole, plus exactly one of mass (aliases mass_g, grams, m, mass_grams) in grams or moles (aliases n, amount, mol). Absolute values must stay within the published limit of one trillion so intermediate products remain finite in IEEE double precision on the Worker and in the browser. On success the response echoes rounded mass, moles, and molar_mass, sets unit_mass to g, unit_moles to mol, unit_molar_mass to g/mol, direction to mass_to_moles or moles_to_mass, formula to n equals m over M or m equals n times M, message to a short English summary, and steps to an ordered array of substitution lines. Failed validation—missing molar_mass, both or neither of mass and moles, non-finite numbers, values outside absolute limits, negative mass or moles, or zero molar 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

When teaching, pair examples: eighteen point zero one five grams of water with M equals eighteen point zero one five yields one mole; two moles of sodium chloride with M equals fifty-eight point four four yields about one hundred sixteen point eight eight grams; and molar_mass equals zero demonstrates the hard invalid_input path. This landing targets people searching for a moles to grams calculator, moles from mass, or n equals m over M online; it is not a molecular-weight look-up from a chemical name, not a full stoichiometry balancer, and not an ideal-gas solver for PV equals nRT. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately set M to zero.

Unit tests for stoichiometry helpers

Generate known-good mass↔moles pairs plus deliberate zero-molar-mass rejections for coding kata and grading pipelines.

What happens if molar mass is zero?

Conversion is undefined. The API returns invalid_input instead of dividing by zero.

Can I send both mass and moles?

No. Provide exactly one of mass or moles together with molar_mass so the direction of conversion is unambiguous.

Read the full KIT documentation →