Chemistry

Percent Composition Calculator

Find the mass percent of every element in a compound, with a bar chart and the grams of each element in your sample. Handles brackets and hydrates.

Real Larzscript running in your browser847 automated checksOpen source · MITNo sign-up · your inputs never leave your device

Enter a formula

Shows the grams of each element in your sample

Percent by mass

Element table

Show the Larzscript program that just ran
Run a calculation to see the exact program.

This is the real program the page sent to the Larzscript interpreter (compiled to WebAssembly) in your browser. The library it imports is the same code the automated tests check.

The formula

mass % of element = (atoms of the element × its atomic weight) ÷ molar mass of the compound × 100

Take iron(III) oxide, Fe2O3, molar mass 159.687 g/mol. Iron contributes 2 × 55.845 = 111.69 g/mol, which is 69.94%; oxygen makes up the other 30.06%. Rust is roughly 70% iron by mass, so 1 tonne of ore of this composition holds about 699 kg of iron.

Worked examples, computed above

Glucose is 40% C, 6.71% H, 53.28% O. Calcium phosphate, the mineral in bone, is 38.76% calcium, 19.97% phosphorus and 41.27% oxygen. Aluminium sulfate, used in water treatment, is 15.77% aluminium, 28.11% sulfur and 56.12% oxygen. Try the presets to see any of them with your own sample mass.

Going the other way

If you have the percentages from an analysis and need the formula, use the empirical formula calculator; to get the molar mass on its own, use the molar mass calculator.

What is verified

The percentages for five compounds are compared with an independent Python computation, and the library also checks that they sum to 100 to 15 digits. Atomic weights are those of the periodic table package, itself cross-checked against PubChem.

Limits: standard atomic weights; neutral formulas only.

Frequently asked questions

What is percent composition?

The share of each element in a compound, by mass. It is each element's total atomic mass in one formula unit divided by the molar mass of the compound, times 100. The percentages always add up to 100.

How do I calculate percent composition?

For each element: (atoms × atomic weight) ÷ molar mass × 100. In glucose, C₆H₁₂O₆, carbon is 6 × 12.011 = 72.066 of 180.156, which is 40%; hydrogen is 6.71% and oxygen 53.28%.

Why is the mass percent of hydrogen small even when there are many hydrogen atoms?

Because hydrogen atoms are light. Glucose has 12 hydrogen atoms out of 24 (half of all atoms), yet they are only 6.71% of the mass.

What is percent composition used for?

Identifying compounds and checking purity, choosing fertilisers (ammonium nitrate, NH₄NO₃, is 35% nitrogen), and finding empirical formulas from lab data — the reverse calculation, done by the empirical formula calculator.

How much of an element is in my sample?

Enter the sample mass: the table shows the grams of each element, which is the mass percent times the sample mass. 500 g of iron(III) oxide, for example, contains 349.7 g of iron.

Does it handle hydrates?

Yes; the water counts as part of the compound. In CuSO₄·5H₂O the copper is 25.45% and the oxygen 57.67%, because oxygen sits in both the sulfate and the water.

Every number on this page is computed by the open-source larzscript-chem library (chemistry, elements, physconst, physmath), written in Larzscript, and checked against independent references in its test suite. How it is verified →