# Moles calculator > How many moles are in your sample? Grams, moles and molecules of any chemical formula, converted through the molar mass and Avogadro's number. Convert grams to moles and molecules for any chemical formula, or back, with the molar mass from IUPAC atomic weights and Avogadro's constant drawn as a chain. - Page: https://how.box/moles/ - Runs entirely in the browser. - License: HowToolbox's own text and data (titles, explanations, FAQs, tool descriptions and schemas, this file) are CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/); AI training and answers are welcome. Attribute "HowToolbox (how.box)" with a link to the page used. Third-party data keeps its own terms; the name and logo are not licensed. Publisher: HowToolbox, contact@how.box. Terms: https://how.box/about/terms/ ## Inputs Answer link: https://how.box/moles/?f={f}&k={k}&g={g}&n={n}&p={p} - `f` (text): The chemical formula, e.g. H2O, NaCl or C6H12O6. Example: `H2O`. - `k` (mass, moles or particles): What is known: mass (default), moles or particles. Example: `mass`. - `g` (number 0 to 1e15): Mass, grams. Example: `100`. - `n` (number 0 to 1e12): Amount, moles. Example: `1`. - `p` (number 0 to 1e36): Number of formula units. Example: `6.02214076e+23`. Example answer: https://how.box/moles/?f=H2O&k=mass&g=100&n=1&p=6.02214076e%2B23 A complete link carries the primary answer in the page HTML; a missing or invalid value shows the default page. ## Agent tools - `moles_calculate`: Mass ↔ moles ↔ particles for a chemical formula: n = m / M (M from IUPAC/CIAAW standard atomic weights) and N = n × N_A (N_A = 6.02214076e23 /mol, exact). - MCP, one POST to https://how.box/mcp: `{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"moles_calculate","arguments":{"formula":"H2O","given":"mass","mass":100,"moles":1,"particles":6.02214076e+23}}}` - GET: https://how.box/mcp/run/moles_calculate?formula=H2O&given=mass&mass=100&moles=1&particles=6.02214076e%2B23 ## How it works Atoms are far too small to count one by one, so chemists count them in moles. One mole is 6.022 × 10²³ particles, Avogadro's constant, chosen so that one mole of a substance weighs its formula mass in grams. A mole of water is 18.015 g, a mole of carbon 12.011 g, and both hold the same number of particles. The chain runs mass → moles → particles: n = m ÷ M and N = n × N_A, where m is the mass in grams, M the molar mass in g/mol (the sum of the atomic weights in the formula), n the amount in moles and N the number of particles. For 100 g of water, n = 100 ÷ 18.015 = 5.551 mol and N = 5.551 × 6.022 × 10²³ = 3.34 × 10²⁴ molecules, each with three atoms. Molar masses use the IUPAC standard atomic weights for elements as found in nature, so a sample enriched in one isotope weighs slightly differently. Particles are formula units: molecules for water, atoms for copper, ion pairs for salt. Sources: OpenStax Chemistry 2e, section 3.1; CIAAW standard atomic weights; BIPM, the SI Brochure. ## FAQ **Should I type O or O2 for oxygen gas?** Use O2 for ordinary oxygen gas, whose molecules contain two oxygen atoms. O describes individual oxygen atoms and gives a different molar mass. **Does the particle count mean molecules or atoms?** It counts the units specified by the formula. For H2O these are molecules, while the separate total-atoms result counts three atoms per molecule. **Can I enter kilograms?** The mass field uses grams. Multiply kilograms by 1000 before entering them. **How do I write hydrates and brackets?** Use a count after brackets, such as Ca(OH)2. Separate hydrate water with a dot or asterisk, as in CuSO4·5H2O or CuSO4*5H2O. **Can I calculate moles in an impure sample?** Use the mass of the substance itself, not the whole sample. For a known mass purity, multiply the sample mass by that fraction first. More: [HowToolbox index](https://how.box/llms.txt) · [Agent Skill](https://how.box/skill.md) · [agent terms](https://how.box/about/agents/)