Percent Composition Calculator
Enter a chemical formula and get the mass percent of every element in it, plus the grams of any element in a sample of that compound.
Percent Composition Calculator
Background.
Percent composition is the percentage by mass of each element in a compound. Enter a chemical formula and this calculator returns the mass percent of every element in it, the molar mass it was computed from, and — if you give it a sample mass — how many grams of any one element that sample actually contains. It is the direct answer to questions like 'how much nitrogen is in ammonium nitrate?', 'what fraction of this ore is iron?' and 'how many grams of copper are in 50 g of copper sulfate?'.
The calculation is one line. For any element E in a compound, the mass percent is the element's atomic weight times how many of its atoms appear in one formula unit, divided by the compound's molar mass, times 100. Ammonium nitrate NH₄NO₃ contains two nitrogens — one in the ammonium ion and one in the nitrate — so its nitrogen contribution is 2 × 14.007 = 28.014 g per 80.043 g of compound, which is 34.998 percent. That is the number behind the '34-0-0' grade printed on a bag of AN fertiliser, and the small gap between the theoretical 35.00 percent and the labelled 34 percent is exactly what an agronomist is looking at when comparing nitrogen sources on a cost-per-kilo-of-N basis.
WHAT THIS PAGE IS NOT, stated here rather than in a collapsed FAQ. This is ELEMENTAL composition of a pure compound, computed from its formula. It is not the mass percent of a solute in a solution — mass of solute divided by mass of solution, the w/w percent that appears on a bottle of hydrochloric acid — which is a different quantity computed from different inputs. And it is a MASS basis, not a mole basis: water is 11.19 percent hydrogen by mass but two atoms in three, 66.7 percent, by count. Mass percent and mole percent are different numbers for the same substance and are not interchangeable.
UNITS AND CONVENTIONS. Formula subscripts are dimensionless counts; atomic weights, the molar mass and the per-mole element mass are in g/mol; the sample mass and the element mass in it are in grams; percentages are percentage points. There is no temperature or pressure basis anywhere on this page — a composition is fixed by the formula and does not change with conditions. Atomic weights come from the CIAAW Abridged Standard Atomic Weights 2024 table, which is the IUPAC Atomic Weights 2021 recommendation with the 2024 revisions to gadolinium, lutetium and zirconium. Elements with no IUPAC standard atomic weight — technetium, promethium, polonium, astatine, radon, francium, radium, actinium and everything heavier than uranium — are refused with an explicit error rather than given an invented value.
A PROPERTY WORTH USING AS A CHECK: the percentages of all elements in a compound sum to exactly 100, because the numerators partition the denominator. If you add up a published analysis and it does not reach 100, an element is missing — and in combustion analysis the missing element is almost always oxygen, which the technique does not measure directly and which is conventionally found by difference. That is the hand-off to the empirical formula calculator, which runs this calculation backwards: give it percentages and it gives you the formula.
READING THE ATOM COUNT OUTPUT. The 'atoms per formula unit' figure exists to catch the most common input error, which is a formula the parser read differently from how you meant it. NH₄NO₃ has two nitrogens and it is easy to type NH4N03 (with a zero) or to forget that the multiplier after a parenthesis applies to everything inside it — Ca(OH)₂ is two oxygens and two hydrogens, not one oxygen and two hydrogens. If the atom count does not match what you intended, fix the formula before reading any of the percentages.
ON ROUNDING. Nothing is rounded during the calculation. The atomic-weight sum, the molar mass and every percentage are carried at arbitrary decimal precision and rounded once, at the end, to ten decimal places. The composition breakdown STRING is shortened to four decimal places purely so it fits on a line; that formatting is display-only and never feeds a numeric output. Report your answer to the significant figures the atomic weights justify — four is almost always the honest ceiling, and for elements whose standard atomic weight CIAAW publishes as an interval rather than a single value (hydrogen, lithium, boron, carbon, nitrogen, oxygen, magnesium, silicon, sulfur, chlorine, argon, bromine, thallium and lead), the real uncertainty in the fourth digit can exceed what the conventional value suggests.
What is percent composition calculator?
Percent composition, sometimes called percentage composition by mass or percent by mass, is the mass fraction of each element in a compound expressed as a percentage. IUPAC's formal term for the underlying quantity is MASS FRACTION, symbol w, defined in the Gold Book as the 'mass of a constituent divided by the total mass of all constituents in the mixture' and sourced to the Green Book; mass percent is that fraction multiplied by 100. For a pure compound of known formula the mass fraction of element E is w(E) = n(E) × A(E) / M, where n(E) is the number of E atoms per formula unit, A(E) is E's standard atomic weight, and M is the compound's molar mass. Three distinctions matter. First, mass basis versus mole basis: the mass fraction of hydrogen in water is 2 × 1.008 / 18.015 = 0.1119, while the MOLE fraction of hydrogen atoms is 2/3 = 0.667. Both are legitimate quantities; they are not the same number and confusing them is a common source of error. Second, elemental composition versus solution concentration: this page computes the former. The 'mass percent' printed on a reagent bottle (37 percent HCl) is the latter — mass of solute over mass of solution — and is a property of a mixture you made, not of a compound. Third, theoretical versus measured: the percentages here are theoretical, derived from the formula and the periodic table. A real elemental analysis of a real sample will differ, and the size of that difference is precisely how purity is assessed — a combustion analysis agreeing with theory to within 0.4 percentage points on carbon is the conventional bar for reporting a new compound as pure.
How to use this calculator.
- Type the chemical formula in Hill/IUPAC notation. Capitalisation matters: Co is cobalt, CO is carbon monoxide, and Na is sodium while NA is nothing.
- Use parentheses for repeated groups, and remember the multiplier applies to everything inside: Ca(OH)2 is one calcium, two oxygens and two hydrogens.
- Write hydrates in expanded form. CuSO4·5H2O becomes CuSO4(H2O)5; the centred dot is not parsed.
- Enter the element you want featured as the headline percentage. Every element appears in the breakdown regardless of what you choose here.
- Check the 'atoms per formula unit' output against what you intended. This is the fastest way to catch a formula the parser read differently from how you meant it.
- Optionally enter a sample mass to get the grams of the featured element in that sample. Leaving it at 100 g makes the answer equal the percentage, which is the 100 gram basis textbooks use.
- Add up the breakdown percentages as a check — they must come to exactly 100.
- To go the other way, from measured percentages to a formula, use the empirical formula calculator.
The formula.
For a compound whose formula gives n(E) atoms of element E per formula unit, the mass of E in one mole of compound is n(E) × A(E) grams, where A(E) is E's standard atomic weight in g/mol. The compound's molar mass is the sum of that quantity over all its elements, M = Σ n(i) × A(i). The mass fraction of E is therefore w(E) = n(E) × A(E) / M, and the mass percent is 100 × w(E).
Because the numerators n(i) × A(i) partition the denominator M exactly, the percentages of all elements sum to precisely 100. That is not an approximation and it is worth using as a check on any composition you are handed.
WORKED THROUGH, for ammonium nitrate NH₄NO₃. The parser reads the formula left to right and ADDS repeated symbols, so NH₄NO₃ becomes 2 N, 4 H and 3 O — not 1 N. The molar mass is 2 × 14.007 + 4 × 1.008 + 3 × 15.999 = 28.014 + 4.032 + 47.997 = 80.043 g/mol. Nitrogen's share is 28.014 / 80.043 × 100 = 34.9987 percent; hydrogen's is 4.032 / 80.043 × 100 = 5.0373 percent; oxygen's is 47.997 / 80.043 × 100 = 59.9640 percent. Those three add to 100.0000.
UNITS. Subscripts are pure counts. Atomic weights, the element mass per mole and the molar mass are all in g/mol, so the ratio in the formula is dimensionless and the ×100 puts it in percentage points. The sample-mass outputs are grams: mass of E in the sample = sample mass × w(E), which is g × (dimensionless) = g.
MASS BASIS, NOT MOLE BASIS. This is the distinction that trips people. The mass fraction of hydrogen in water is 2 × 1.008 / 18.015 = 0.1119, so water is 11.19 percent hydrogen BY MASS. Two of water's three atoms are hydrogen, so it is 66.7 percent hydrogen BY MOLE FRACTION. Both statements are true and they describe different quantities. Elemental analysis, fertiliser grades, ore assays and pharmacopoeial assays are all mass-based; reaction stoichiometry is mole-based.
ROUNDING STAGE. No intermediate rounding. The atomic-weight sum, the molar mass, every percentage and the sample-mass conversion are all carried at arbitrary decimal precision and rounded once, at the return boundary, to ten decimal places. The composition breakdown string is separately truncated to four decimal places so it fits on one line; that is display formatting only and never feeds a numeric output.
SIGNIFICANT FIGURES. Four significant figures is almost always the honest ceiling, because that is roughly where the standard atomic weights themselves stop being sharp. For the fourteen elements whose standard atomic weight CIAAW publishes as an INTERVAL rather than a single value — hydrogen, lithium, boron, carbon, nitrogen, oxygen, magnesium, silicon, sulfur, chlorine, argon, bromine, thallium and lead — the genuine uncertainty in the fourth digit can be larger than the conventional single value implies. This calculator uses the conventional (abridged) values, which is what every textbook quotes.
INVALID DOMAIN. An empty or unparseable formula, an unbalanced parenthesis, a stray character, an unknown element symbol, a subscript of zero, an element that does not appear in the formula you entered, a wrongly-cased symbol, and a negative sample mass all raise a field error naming the specific fault. Elements with no IUPAC standard atomic weight are refused rather than guessed. A sample mass of exactly zero is accepted and simply reports 0 g of the element.
A worked example.
Worked example — nitrogen in ammonium nitrate, the fertiliser sold as grade '34-0-0'. Type NH4NO3 and choose N. The parser adds the two separate nitrogen symbols together, so the formula unit is 2 N, 4 H and 3 O — the 'atoms per formula unit' output reads 2, which is the check that the formula was read correctly. Using the CIAAW abridged 2024 atomic weights (N = 14.007, H = 1.0080, O = 15.999), the molar mass is 2 × 14.007 + 4 × 1.008 + 3 × 15.999 = 28.014 + 4.032 + 47.997 = 80.043 g/mol. Nitrogen contributes 28.014 g of every 80.043 g, so the mass percent is 28.014 / 80.043 × 100 = 34.9987 percent. The breakdown line reads 'H 5.0373 %, N 34.9987 %, O 59.964 %' — Hill order puts hydrogen first here because the compound contains no carbon and the remaining symbols sort alphabetically — and those three figures add to exactly 100.0000. With the sample mass left at the default 100 g, the 'element in your sample' output also reads 34.9987 g, which is the whole point of the 100 gram basis: on 100 g the percentage and the mass are the same number. Change the sample mass to 50000 g, a 50 kg bag, and it becomes 17499.34 g — just under 17.5 kg of nitrogen per bag. That is the number a grower needs to compare AN against urea, CO(NH2)2, which this calculator gives as 46.6465 percent nitrogen: urea carries a third more nitrogen per kilogram of product, which is why it dominates where freight cost matters. Two more checks worth running. Aspirin, C9H8O4 with C selected, returns 60.0020 percent carbon, 4.4760 percent hydrogen and 35.5220 percent oxygen against a molar mass of 180.159 g/mol — the figures OpenStax prints as 60.00, 4.476 and 35.52. And hematite, Fe2O3 with Fe selected, returns 69.9431 percent iron, the theoretical grade of a pure iron ore.
Frequently asked questions.
How do you calculate percent composition?
Is percent composition by mass or by moles?
Why does NH4NO3 give two nitrogens?
Is this the same as mass percent of a solution?
Why does percent nitrogen in fertiliser matter?
Do the percentages always add up to exactly 100?
How many significant figures should I report?
How do I handle a hydrate like CuSO4·5H2O?
Where do the atomic weights come from?
References& sources.
- [1]Flowers, P., Theopold, K., Langley, R. & Robinson, W. R. (2019). Chemistry 2e, Section 3.2 'Determining Empirical and Molecular Formulas'. OpenStax, Rice University. Peer-reviewed, CC BY 4.0. PRIMARY SOURCE: defines percent composition as 'the percentage by mass of each element in the compound', and works Example 3.10 (aspirin C9H8O4 → 60.00 % C, 4.476 % H, 35.52 % O) and its Check Your Learning (Fe2O3 → 69.9 % Fe), both of which are asserted against this calculator in its test suite. Retrieved 2026-07-29. Open access.
- [2]IUPAC. Compendium of Chemical Terminology (the Gold Book), 'mass fraction, w' (M03722): 'Mass of a constituent divided by the total mass of all constituents in the mixture.' Sourced there to the Green Book 2nd ed. p. 41 and to Pure Appl. Chem. 1996, 68, 957 (Glossary of terms in quantities and units in Clinical Chemistry, IUPAC-IFCC Recommendations 1996) p. 980. SECOND, INDEPENDENT AUTHORITY consulted for this page: it agrees with the OpenStax definition, supplies the formal name and symbol for the quantity, and is the basis for this page's explicit separation of MASS fraction from MOLE fraction. Retrieved 2026-07-29 via the legacy IUPAC host (the current goldbook.iupac.org returns HTTP 403 to automated retrieval). Open access.
- [3]Meija, J. et al. (2021). 'Atomic weights of the elements 2021 (IUPAC Technical Report)'. Pure and Applied Chemistry 93(5), 573–600, doi:10.1515/pac-2019-0603, as maintained in the CIAAW table 'Abridged Standard Atomic Weights 2024' (named revision: 2024, incorporating the Gd, Lu and Zr revisions on the Atomic Weights 2021 base). The named, versioned source of every atomic weight used here — N 14.007, H 1.0080, O 15.999, C 12.011, Fe 55.845, S 32.06, Al 26.982. Also the source for the list of fourteen elements whose standard atomic weight is published as an interval rather than a single value, which is why four significant figures is the honest ceiling on this page. Retrieved 2026-07-29. Open access.
- [4]IUPAC (2007). Quantities, Units and Symbols in Physical Chemistry ('the Green Book'), 3rd edition (2nd printing 2008), section 2.10 on composition of mixtures — the governing definitions of mass fraction, mole fraction, and the distinction between them that this page turns on. International Union of Pure and Applied Chemistry / RSC Publishing. Retrieved 2026-07-29. Bibliographic reference: a print and PDF edition rather than a live web page.
- [5]NIST Chemistry WebBook, Standard Reference Database Number 69, National Institute of Standards and Technology. Searchable by formula and molecular weight; used to confirm the molar masses quoted on this page — ammonium nitrate NH4NO3 80.04 g/mol, aspirin C9H8O4 180.16 g/mol, urea CH4N2O 60.06 g/mol, iron(III) oxide Fe2O3 159.69 g/mol. Retrieved 2026-07-29. Open access.
- [6]Hill, E. A. (1900). 'On a system of indexing chemical literature; adopted by the Classification Division of the U.S. Patent Office'. Journal of the American Chemical Society 22(8), 478–494, doi:10.1021/ja02046a005. The origin of the ordering used in this page's composition breakdown — carbon first, hydrogen second, all remaining elements alphabetically, and for carbon-free compounds every element alphabetically (which is why the ammonium nitrate breakdown begins with hydrogen). Adopted by Chemical Abstracts and by IUPAC formula indexes. Retrieved 2026-07-29. Publisher page paywalled; record and abstract open.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 682 calculators remain free
- No billing is enabled