Water is two hydrogen atoms and one oxygen atom, so by count it is two thirds hydrogen. By mass it is almost nine tenths oxygen. Both statements are true, and the difference between them is the whole point of percent composition: atoms do not all weigh the same, so counting atoms and weighing them give very different answers. This free percent composition calculator takes a chemical formula and works out the percent by mass of every element in it, with the molar mass, the atom count for each element, and the atom share shown alongside so the two kinds of percent are never confused.
At the defaults, H2O, the molar mass is 18.015 g/mol, hydrogen is 11.19 percent by mass and oxygen is 88.81 percent by mass. By atom count the same molecule is 66.67 percent hydrogen and 33.33 percent oxygen. The calculator states both figures openly, because quoting the atom share as the mass percent is the most common mistake with this calculation, and it is a large one: for water it would overstate hydrogen by more than five times.
Type a formula the way it is written in a textbook, such as H2O, CO2 or C6H12O6. Element symbols start with a capital letter and may have one lowercase letter, and a number after an element or a bracketed group is its count, so Ca(OH)2 means one calcium, two oxygens and two hydrogens. Percentages are by mass, not by atom count: the calculator shows both, so you can see how different they are. Atomic weights are the IUPAC 2021 conventional values.
| Element | Atoms | Atom Share | Mass in 1 mol | Percent by Mass |
|---|---|---|---|---|
| Hydrogen (H) | 2 | 66.67% | 2.016 g | 11.19% |
| Oxygen (O) | 1 | 33.33% | 15.999 g | 88.81% |
Enter a chemical formula, such as H2O or Ca(OH)2.
| Compound | Formula | Molar Mass (g/mol) | Composition by Mass |
|---|
Eight common compounds, worked out with the same IUPAC 2021 atomic weights. The row matching the formula you entered is highlighted. At the default, H2O, the water row is highlighted.
ADVERTISEMENT
Founder & CEO, Techraxy
Faiq Ur Rahman is a web designer, digital product developer, and Founder of Techraxy, a growing platform of online calculators and utility tools. He specializes in building structured, user-friendly tools focused on finance, health, conversions, productivity, and everyday problem-solving. He is passionate about developing practical digital solutions that make complex tasks simpler for users worldwide.
User Ratings:
ADVERTISEMENT
ADVERTISEMENT
A percent composition calculator is a tool that turns a chemical formula into the percent by mass of each element in the compound. The formula for one element is its percent equals its count times its atomic weight, divided by the molar mass of the compound, times 100. The molar mass is the sum of count times atomic weight over all the elements in the formula. The percentages of all the elements add up to 100 percent, which is a built in check on the arithmetic: if they do not add to 100, something is wrong.
Percent composition is always by mass unless someone says otherwise. That convention matters because the alternative, percent by atom count, is easy to work out and easy to mistake for the answer. In carbon dioxide, CO2, oxygen is two of three atoms, 66.67 percent by count, but 72.71 percent by mass, because each oxygen atom weighs about a third more than a carbon atom. In glucose, C6H12O6, carbon is 6 of 24 atoms, 25.00 percent by count, but 40.00 percent by mass. The heavier the element, the further its mass share sits above its atom share.
The atomic weights used here are the IUPAC 2021 conventional standard values, the single value form published by the IUPAC Commission on Isotopic Abundances and Atomic Weights. They describe elements of natural terrestrial origin. A sample with an artificially enriched isotope mix would need its own molar mass instead, but for ordinary classroom and laboratory compounds the conventional values are the right ones, and they are the values most textbooks use.
Type a chemical formula in the box, the way it is written in a textbook, such as H2O, CO2, NaCl or C6H12O6. Element symbols start with a capital letter and may have one lowercase letter, so write NaCl, not NACL or nacl. A number after an element is its count, and a number after a closing parenthesis multiplies everything inside the brackets, so Ca(OH)2 means one calcium, two oxygens and two hydrogens, and Fe2(SO4)3 means two irons, three sulfurs and twelve oxygens. The calculator updates as you type, and the Calculate button runs it again at any time.
Read the results in order. The molar mass comes first, in grams per mole, then the total number of atoms in one formula unit, then the breakdown table. Each row of the table gives one element, its atom count, its atom share, its mass in one mole of the compound, and its percent by mass. The percentages sum to 100.00 percent, and the sum is shown so you can check it. The highlight line under the results states the composition in one sentence, and the diagram above the results shows the same numbers as a stacked bar and as balls sized by mass share, so a change of formula changes the picture visibly.
If the formula cannot be read, the calculator says so plainly and dashes out the results. An empty box, a lowercase symbol such as h2o, a formula starting with a number such as 2H2O, an unknown symbol such as Xx, a count of zero, and an unbalanced parenthesis all produce their own error message. Nested parentheses, such as a bracket inside a bracket, are not supported and are rejected with an error. Hydrate formulas written with a dot, such as CuSO4.5H2O, are also not supported: enter the anhydrous formula instead, or work out the hydrate by adding the water molecules to the counts by hand.
The Compare Compounds tab puts eight common compounds side by side: water, carbon dioxide, sodium chloride, methane, glucose, ammonia, calcium carbonate and sulfuric acid, each with its molar mass and its composition by mass. The row matching the formula you entered is highlighted, so you can check your own entry against a known compound at a glance.
The formula for one element is percent by mass equals count times atomic weight, divided by molar mass, times 100. The molar mass is the sum of count times atomic weight for every element in the formula. Written out for the defaults, H2O: hydrogen contributes 2 times 1.008, which is 2.016 g, and oxygen contributes 1 times 15.999, which is 15.999 g, so the molar mass is 2.016 plus 15.999, which is 18.015 g/mol. Hydrogen is 2.016 divided by 18.015, times 100, which is 11.19 percent. Oxygen is 15.999 divided by 18.015, times 100, which is 88.81 percent. The two percentages add to 100.00 percent.
Atom share uses a different denominator: it is count divided by total atoms, times 100. For H2O that is 2 divided by 3, times 100, which is 66.67 percent hydrogen, and 1 divided by 3, times 100, which is 33.33 percent oxygen. The two kinds of percent share the same counts but different weights, which is why they differ whenever the elements have different atomic weights. They agree only when every element in the formula happens to weigh the same, which is rare.
Percentages are shown to two decimal places. Rounding to two places can leave the displayed values adding to 99.99 or 100.01 instead of 100.00, so the calculator adds the rounding remainder to the largest element, and the displayed percentages always sum to exactly 100.00 percent. That adjustment is at most 0.01 percent, it always falls on the element with the largest mass share, and it is the reason glucose shows oxygen at 53.29 percent rather than the unrounded 53.28 percent. The underlying molar mass is never adjusted, only the displayed rounding.
Take carbon dioxide, CO2, the worked example used through this article. First list the counts: one carbon atom and two oxygen atoms, three atoms in total. Then multiply each count by its IUPAC 2021 atomic weight: carbon contributes 1 times 12.011, which is 12.011 g, and oxygen contributes 2 times 15.999, which is 31.998 g. Add them for the molar mass: 12.011 plus 31.998 is 44.009 g/mol.
Now divide each contribution by the molar mass and multiply by 100. Carbon is 12.011 divided by 44.009, times 100, which is 27.29 percent. Oxygen is 31.998 divided by 44.009, times 100, which is 72.71 percent. The two add to 100.00 percent, which is the check that the arithmetic is right. By atom count the same molecule is 33.33 percent carbon and 66.67 percent oxygen, which is a different pair of numbers and must not be quoted as the composition by mass.
A second check with a bracketed formula shows the parser at work. Calcium hydroxide, Ca(OH)2, has one calcium, and the bracketed OH group appears twice, so two oxygens and two hydrogens. Calcium contributes 1 times 40.078, which is 40.078 g, oxygen contributes 2 times 15.999, which is 31.998 g, and hydrogen contributes 2 times 1.008, which is 2.016 g. The molar mass is 40.078 plus 31.998 plus 2.016, which is 74.092 g/mol. The percentages are calcium 54.09 percent, oxygen 43.19 percent and hydrogen 2.72 percent, which add to 100.00 percent.
The first benefit is getting the mass percent right without the most common error. The atom share of hydrogen in water, 66.67 percent, looks like an answer and is easy to quote by mistake, but the mass percent is 11.19 percent, and the two differ by a factor of almost six. Showing both figures side by side, with the mass percent as the headline, makes the distinction hard to miss, and the diagram makes it visible: the oxygen ball is far larger than the hydrogen ball even though there is only one oxygen atom.
The second benefit is checking a formula or a sample. The percent composition of a pure compound is fixed, so a measured composition that does not match the calculated one means the sample is impure, the formula is wrong, or the wrong compound was weighed out. A student who synthesises a salt and finds 39.34 percent sodium and 60.66 percent chlorine has sodium chloride, NaCl, and a student who finds anything else does not. The sum to 100.00 percent is a second check built into the same table.
The third benefit is handling brackets without hand arithmetic. Formulas such as Ca(OH)2 and Fe2(SO4)3 are easy to miscount by hand, because the multiplier after a bracket applies to every element inside it. The parser multiplies the whole group, so Fe2(SO4)3 correctly counts twelve oxygens, not four, and the molar mass comes out at 399.858 g/mol with iron at 27.93 percent, sulfur at 24.05 percent and oxygen at 48.02 percent. Counting by hand is where the error usually creeps in, and the calculator removes that step.
The fourth benefit is seeing common compounds next to each other. The Compare Compounds tab shows that table salt is 39.34 percent sodium and 60.66 percent chlorine, that methane is 74.87 percent carbon and 25.13 percent hydrogen by mass even though it is 80.00 percent hydrogen by atom count, and that glucose is 40.00 percent carbon, 6.71 percent hydrogen and 53.29 percent oxygen. Those comparisons build the instinct that light elements contribute far less mass than their atom counts suggest, which is the idea the whole calculator exists to teach.
Multiply each element’s count by its atomic weight to get its mass in one mole, add those masses for the molar mass, then divide each element’s mass by the molar mass and multiply by 100. For CO2: carbon is 1 times 12.011, which is 12.011 g, oxygen is 2 times 15.999, which is 31.998 g, the molar mass is 44.009 g/mol, so carbon is 12.011 divided by 44.009, times 100, which is 27.29 percent, and oxygen is 72.71 percent. Use IUPAC standard atomic weights, not whole number masses, or the answer will be slightly off.
It is by mass, unless someone says otherwise. Percent composition means the percent by mass of each element in a compound, which is the mass of that element in one mole divided by the molar mass, times 100. Percent by atom count is a different figure: in water, hydrogen is 66.67 percent by atom count but only 11.19 percent by mass. This calculator shows both, with the mass percent as the headline, so the two are never confused.
Because every gram of the compound belongs to one of its elements, so the mass shares must cover the whole. The calculator shows the sum, 100.00 percent, as a check on the arithmetic. If percentages you worked out by hand do not add to 100, either a mass was left out, an atomic weight is wrong, or a count in the formula is wrong. Rounding to two decimal places can leave a raw total of 99.99 or 100.01, so this calculator adds the rounding remainder to the largest element and the displayed values always sum to exactly 100.00 percent.
The IUPAC 2021 conventional standard atomic weights, the single value form from Prohaska and co-workers, Pure and Applied Chemistry 2022, volume 94, pages 573 to 600. Common values are hydrogen 1.008, carbon 12.011, nitrogen 14.007, oxygen 15.999, sodium 22.990, magnesium 24.305, sulfur 32.06, chlorine 35.45, potassium 39.098, calcium 40.078, iron 55.845, copper 63.546 and zinc 65.38. The widget carries 48 elements in total. These values describe elements of natural terrestrial origin; an isotopically enriched sample would need its own molar mass.
Type it exactly as written, with the multiplier after the closing parenthesis: Ca(OH)2. The number after the bracket multiplies every element inside it, so Ca(OH)2 counts one calcium, two oxygens and two hydrogens, and Fe2(SO4)3 counts two irons, three sulfurs and twelve oxygens. Do not put a space inside the formula, do not use square brackets, and do not use a dot for hydrates: CuSO4.5H2O is not supported, and nested parentheses are not supported either. If the formula cannot be read, the calculator shows an error message that says what is wrong.
LibreTexts — Mass percent composition from a chemical formula, with the formula that the mass of each element in one mole is divided by the molar mass and multiplied by 100 percent, and the check that the percentages add up to 100 percent.
LibreTexts — Percent composition, defining it as the percent by mass of each element in a compound, with the same formula applied to mass data and to a chemical formula.
IUPAC — Atomic weights of the elements 2021, the Commission on Isotopic Abundances and Atomic Weights table giving hydrogen 1.008, carbon 12.011, nitrogen 14.007, oxygen 15.999 and sodium 22.990.
Wikipedia — Molar mass, with the definition that it is the sum of the atomic weights of the atoms in a formula, and the use of grams per mole.
Wikipedia — Percent composition, with the definition as the percent by mass of each element in a compound and the formula dividing the mass of the element by the total mass.
This calculator works out percent composition by mass from the formula you enter, using the IUPAC 2021 conventional standard atomic weights, and it is for study, homework and laboratory preparation only. It assumes the formula you enter is correct and the compound is pure: it cannot tell you whether the formula itself is right, whether a sample is impure, or whether a hydrate or a salt with water of crystallisation should have been entered instead. The atomic weights describe elements of natural terrestrial origin, so an isotopically enriched or depleted sample will give a different true molar mass. The percentages are rounded to two decimal places, with the rounding remainder added to the largest element so the displayed values sum to exactly 100.00 percent, which is a display convention, not a change to the underlying masses. Nested parentheses and dot hydrates are not supported. For analytical work, check the result against a reference table or a laboratory measurement before relying on it.
Last updated: 29 November 2026
ADVERTISEMENT
ADVERTISEMENT