Atom Counter in a Compound
Count every atom of every element in a chemical formula, with nested brackets and hydrates such as CuSO4.5H2O read correctly.
Every atom in one formula unit
Type a formula and the page counts the atoms of each element, then prints the total. Nested brackets are multiplied out, so Ca(OH)2 gives two oxygen and two hydrogen, and K4[Fe(CN)6] gives six carbon and six nitrogen. A hydrate is read as its parts: CuSO4.5H2O is one copper sulfate plus five waters, which is nine oxygen and ten hydrogen.
A formula the parser cannot read is refused by name, never half-counted. An unknown symbol, a bracket with no partner, a stray character and a count of zero each produce a message that says what to fix, and a leading coefficient before the first formula is refused with the hydrate-dot form suggested instead.
The count is pure arithmetic on the text you type. Reloading the page and typing the same formula gives the same count, and nothing leaves the browser.
Type a formula and the page counts the atoms of every element in one formula unit, then prints the total. Subscripts multiply through nested brackets, so Ca(OH)2 gives two oxygen and two hydrogen and K4[Fe(CN)6] gives six carbon and six nitrogen; a hydrate dot is read as a sum, so CuSO4.5H2O is one copper sulfate plus five waters, which is nine oxygen and ten hydrogen.
The count is a parse of the text you type, not a lookup: no name, charge or coefficient in front of the formula is accepted, and an element the parser does not recognise is named instead of being given a count.
How to use it
Type a formula into the box in the usual notation and press Run. Accepted syntax is element symbols with optional integer subscripts, nested round or square brackets, and a dot for hydrates, as in CuSO4.5H2O or Al2(SO4)3.18H2O. Lower-case subscripts are not valid chemistry and a count of zero is not a count, so both are refused.
- Enter the formula with brackets, not expanded: Al2(SO4)3, not Al2S3O12.
- Write a hydrate with a dot and a leading coefficient: CuSO4.5H2O.
- Read the per-element counts first, then the total beneath them.
The arithmetic, and where it stops
Counting is a walk over the parsed formula: a subscript multiplies everything to its left inside the current bracket group, and a closing bracket folds its group into the one outside it. The hydrate dot splits the formula into parts and each part is counted on its own before they are added, which is why CuSO4.5H2O needs no special case and why the five leading waters contribute ten hydrogen rather than one.
A formula the parser cannot read is refused by name and never half-counted: an unknown symbol, an unclosed or stray bracket, a stray character and a subscript of zero each print a message saying what to fix, and a leading coefficient before the first formula is refused with the hydrate-dot form suggested instead.
What to Expect
Best for
- Checking a formula's atom count before a molar mass, a yield or a balancing problem.
What this tool keeps
- The formula is parsed in this tab; nothing about the compound is posted, stored or remembered. The same figures give the same result after a reload.
Sample input
CuSO4.5H2O
Sample output
Cu 1, S 1, O 9, H 10 total atoms = 21
Frequently asked questions
How do I use the Atom Counter in a Compound?
Type a formula into the box in the usual notation and press Run. Accepted syntax is element symbols with optional integer subscripts, nested round or square brackets, and a dot for hydrates, as in CuSO4.5H2O or Al2(SO4)3.18H2O. Lower-case subscripts are not valid chemistry and a count of zero is not a count, so both are refused.
Does anything leave my browser?
No. The formula is parsed in this tab; nothing about the compound is posted, stored or remembered. Reloading the page discards every value you entered.
Which inputs does it refuse?
A formula the parser cannot read is refused by name and never half-counted: an unknown symbol, an unclosed or stray bracket, a stray character and a subscript of zero each print a message saying what to fix, and a leading coefficient before the first formula is refused with the hydrate-dot form suggested instead.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.