Home › Chemistry › Moles to Grams Calculator
Moles to Grams Calculator
Converts between mass in grams and amount in moles using the molar mass (from a formula or given directly), and reports the number of molecules or formula units from the Avogadro constant. Any two of molar mass, mass and moles give the third.
When to use
You need to convert grams to moles or moles to grams for a substance, count the molecules in a sample, or back out a molar mass from a measured mass and amount.
Do not use when: You only need the molar mass of a formula (use molar-mass), or you want a concentration in mol/L (use molarity).
Formula
moles = mass_g / molar_mass_g_mol; mass_g = moles × molar_mass_g_mol; molecules = moles × N_A (N_A = 6.02214076×10²³ mol⁻¹)
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
formula | string | no | Chemical formula, e.g. NaCl, C6H12O6, Ca(OH)2 or CuSO4·5H2O (case-sensitive element symbols). Alternative to molar_mass_g_mol. | |
molar_mass_g_mol | number | g/mol | no | Molar mass of the substance; use instead of formula when it is already known. Range: > 0, ≤ 10000000 |
mass_g | number | g | no | Mass of the sample in grams. Leave empty to solve for it. Range: > 0 |
moles | number | mol | no | Amount in moles. Leave empty to solve for it. Range: > 0 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
molar_mass_g_mol | number | g/mol | Molar mass used or derived (mass_g / moles). |
mass_g | number | g | Mass of the sample. |
moles | number | mol | Amount of substance. |
millimoles | number | mmol | Amount in millimoles. |
molecules | number | moles × 6.02214076×10²³ (molecules for molecular substances, formula units for ionic compounds, atoms for elements). | |
molecules_scientific | string | The same count in scientific notation. | |
solved_for | string | Which quantity was computed: mass_g, moles or molar_mass_g_mol. |
Example
36.03 g of water: {"formula":"H2O","mass_g":36.03} → {"molar_mass_g_mol":18.015,"moles":2,"millimoles":2000,"molecules":1.204428152e+24,"solved_for":"moles"}
0.5 mol of CO2: {"formula":"CO2","moles":0.5} → {"molar_mass_g_mol":44.009,"mass_g":22.0045,"molecules":3.01107038e+23,"solved_for":"mass_g"}
GET https://tttkmbb.com/api/v1/calculate/moles-mass?formula=H2O&mass_g=36.03
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/moles-mass(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/moles-mass · Markdown: https://tttkmbb.com/chemistry/moles-mass.md · JSON definition: https://tttkmbb.com/chemistry/moles-mass.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="moles-mass" - OpenAPI operationId:
convert_moles_and_mass - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- NIST – CODATA internationally recommended values of the fundamental physical constants (Avogadro constant N_A = 6.02214076×10²³ mol⁻¹, exact) (standard)
- IUPAC – Atomic Weights of the Elements (2021 table with 2023 revisions, Queen Mary University of London mirror) (standard)
- OpenStax Chemistry 2e – 3.1 Formula Mass and the Mole Concept (textbook)
FAQ
How do I get the molar mass without a formula?
Give molar_mass_g_mol directly, or give both mass_g and moles and the calculator returns molar_mass_g_mol = mass_g / moles (useful for identifying an unknown).
Does 'molecules' apply to ionic compounds?
For NaCl or CaCO3 the count is formula units rather than discrete molecules; for a monatomic element it is the number of atoms.
Related calculators
- Molar Mass Calculator — Look up or check the molar mass and composition of the formula.
- Molarity Calculator — Use the moles to compute a solution concentration.
- Ideal Gas Law Calculator — Relate moles of a gas to its pressure, volume and temperature.