Key points at a glance
- A chemical formula tells you which elements are in a compound and how many atoms of each there are.
- A formula is built so that the combining powers balance: the total positive charge must exactly cancel the total negative charge.
- The charge on a main-group ion comes straight from its group in the periodic table – group 1 gives 1+, group 2 gives 2+, group 6 gives 2−, group 7 gives 1−.
- The quickest method is swap and drop: swap the two numbers, write them as subscripts, then simplify to the lowest whole-number ratio.
- A polyatomic ion such as nitrate (NO3-) or sulfate (SO42-) is a group of atoms with one overall charge. If you need more than one of them, put it in brackets.
- A subscript of 1 is never written, and a subscript applies only to the symbol immediately before it.
How to write chemical formula
Compounds are formed by the chemical bonding of atoms or ions of elements. The formula is built in such a way that the combining powers are balanced.
While formulating a compound formula, its combining powers or valency should be known.
What is Valency?
Valence electrons are the electrons in the outermost shell of an atom, and valency is the combining power of that element – the number of electrons an atom loses, gains or shares when it forms a compound.
For main-group elements you can read the valency straight off the periodic table:
- Groups 1, 2 and 3 lose electrons, so the valency equals the group number: 1, 2 and 3.
- Groups 5, 6 and 7 gain electrons, so the valency is 8 minus the group number: 3, 2 and 1.
- Group 4 usually shares four electrons, so the valency is 4.
- Group 0 elements already have full outer shells, so their valency is 0 – this is why the noble gases are so unreactive.
Note that valency is not simply the number of outer electrons. Oxygen has six outer electrons but a valency of two, because it only needs two more to fill its shell. Some elements, particularly the transition metals, have more than one valency, which is why their names carry a Roman numeral: iron(II) means a valency of 2 and iron(III) means a valency of 3.
Charges on common ions
For ionic compounds it is usually easier to think in terms of charge rather than valency, because the sign tells you which ion goes first in the formula.
| Group | Charge on the ion | Examples |
|---|---|---|
| 1 | 1+ | Li+, Na+, K+ |
| 2 | 2+ | Mg2+, Ca2+, Ba2+ |
| 3 | 3+ | Al3+ |
| 5 | 3− | N3-, P3- |
| 6 | 2− | O2-, S2- |
| 7 | 1− | F-, Cl-, Br-, I- |
| 0 | No ions formed | He, Ne, Ar |
The transition metals do not follow a group rule. The ones worth learning are Zn2+, Ag+, Cu2+, Fe2+ and Fe3+. Where two are possible, the question will always tell you which by using a Roman numeral. If you want to understand where these charges come from, our lesson on electronic configuration explains the shell structure behind them.
Valencies of several elements in a table
| Element | Valency |
|---|---|
| Hydrogen | 1 |
| Helium | 0 |
| Lithium | 1 |
| Beryllium | 2 |
| Boron | 3 |
| Carbon | 4 |
| Nitrogen | 3, 5 |
| Oxygen | 2 |
| Fluorine | 1 |
| Neon | 0 |
| Sodium | 1 |
| Magnesium | 2 |
| Aluminium | 3 |
| Silicon | 4 |
| Phosphorus | 3, 5 |
| Sulfur | 2, 4, 6 |
| Chlorine | 1 |
| Argon | 0 |
| Potassium | 1 |
| Calcium | 2 |
Number of atoms in a compound's formula
A number written low and small after an element's symbol – a subscript – gives the number of atoms of that element in one unit of the compound.
Number of atoms in the glucose formula
C6H12O6 is the chemical formula for glucose. This means that a glucose molecule is made up of six carbon atoms, twelve hydrogen atoms, and six oxygen atoms – twenty-four atoms in total.
The swap-and-drop method
Almost every ionic formula can be written in four steps. Learn the sequence and it works every time.
- Write the two ions with their charges, positive one first. For example Ca2+ and Cl-.
- Swap the numbers. Take the size of each charge (ignoring the sign) and write it as the subscript of the other ion. The 2 from calcium goes to chlorine; the 1 from chloride goes to calcium.
- Drop the 1s. A subscript of 1 is never written, so Ca1Cl2 becomes CaCl2.
- Simplify if you can. The formula must be the lowest whole-number ratio. Mg2O2 would simplify to MgO.
Finally, check your answer: multiply each charge by its subscript and confirm the positives and negatives cancel. In CaCl2 that is (+2) + (2 × −1) = 0. Correct.
Writing Formulae Using Valency
As a compound's chemical formula is written, the atoms are combined so that their combining powers balance. This is done by swapping the valencies of the two elements and writing them as subscripts on the right of the respective symbols.
Writing the formula for water
The chemical formula for water is H2O. It consists of two hydrogen atoms (H) and one oxygen atom (O) held together by covalent bonds. Hydrogen has a valency of 1 and oxygen a valency of 2, so two hydrogen atoms are needed for every one oxygen atom.
How to write the formula for ammonia
The chemical formula for ammonia is NH3. It consists of one nitrogen atom (N) and three hydrogen atoms (H). Nitrogen has a valency of 3 and hydrogen a valency of 1, so three hydrogen atoms are needed. The nitrogen and hydrogen atoms are held together by covalent bonds, which means they share electrons to form a stable molecule.
Simple way of writing formulae
Chemical formulae describe a substance's chemical makeup using chemical symbols and subscripts to show the number of atoms of each element. The formula represents the material in a clear and brief manner that can be used to convey its chemical properties and behavior.
To write a formula for a compound, you need to identify the elements that make up the compound and their respective numbers. The elements are represented by their chemical symbols, such as H for hydrogen, O for oxygen, and C for carbon. The number of atoms of each element is indicated by a subscript written to the right of the element symbol. For example, H2O indicates that there are two hydrogen atoms and one oxygen atom in a water molecule.
Some basic rules to follow when writing chemical formulas are:
- The formula should have the lowest whole number ratios of atoms.
- The number of atoms of each element in the compound should be indicated by subscripts, not by a separate number next to the element symbol.
- If there is only one atom of an element, the subscript 1 is usually omitted.
- The positive ion is written first, then the negative ion.
- Element symbols always take a capital first letter and, where there is a second letter, a small one. Co is cobalt; CO is carbon monoxide.
Six worked examples
1. Calcium oxide
Ions: Ca2+ and O2-. The charges are equal and opposite, so one of each is enough. Swapping gives Ca2O2, which simplifies to CaO. Check: (+2) + (−2) = 0.
2. Sodium oxide
Ions: Na+ and O2-. Two sodium ions are needed to balance one oxide ion. Swapping the 1 and the 2 gives Na2O. Check: (2 × +1) + (−2) = 0.
3. Sodium chloride
Ions: Na+ and Cl-. Both charges are 1, so one of each balances: NaCl. Check: (+1) + (−1) = 0.
4. Calcium chloride
Ions: Ca2+ and Cl-. Two chloride ions are needed for each calcium ion, giving CaCl2. Check: (+2) + (2 × −1) = 0.
5. Magnesium nitride
Ions: Mg2+ and N3-. Swapping gives three magnesium ions and two nitride ions: Mg3N2. Check: (3 × +2) + (2 × −3) = +6 − 6 = 0.
6. Aluminium oxide
Ions: Al3+ and O2-. Swapping gives two aluminium ions and three oxide ions: Al2O3. Check: (2 × +3) + (3 × −2) = +6 − 6 = 0. This is the compound extracted to make aluminium by electrolysis.
When a compound has polyatomic ions or radicals
What are polyatomic ions?
A polyatomic ion is a group of covalently bonded atoms that carries a single overall charge and travels around as one unit. Sulfate, SO42-, is not a sulfur ion plus four oxygen ions – it is one particle with a 2− charge. Older textbooks sometimes call these radicals.
Table of common polyatomic ions
| Name | Formula | Charge |
|---|---|---|
| Ammonium | NH4+ | 1+ |
| Hydroxide | OH- | 1− |
| Nitrate | NO3- | 1− |
| Nitrite | NO2- | 1− |
| Hydrogencarbonate (bicarbonate) | HCO3- | 1− |
| Ethanoate (acetate) | CH3COO- | 1− |
| Chlorate | ClO3- | 1− |
| Chlorite | ClO2- | 1− |
| Cyanide | CN- | 1− |
| Permanganate | MnO4- | 1− |
| Carbonate | CO32- | 2− |
| Sulfate | SO42- | 2− |
| Sulfite | SO32- | 2− |
| Chromate | CrO42- | 2− |
| Dichromate | Cr2O72- | 2− |
| Oxalate | C2O42- | 2− |
| Peroxide | O22- | 2− |
| Thiosulfate | S2O32- | 2− |
| Phosphate | PO43- | 3− |
Writing formulae for compounds with polyatomic ions
The method is identical, with one extra rule: if you need more than one polyatomic ion, put brackets round it and write the number outside. The brackets say "take everything inside this, that many times".
Magnesium nitrate
Ions: Mg2+ and NO3-. Two nitrate ions are needed, so the formula is Mg(NO3)2 – one magnesium, two nitrogens and six oxygens. Writing MgNO32 would be meaningless.
Sodium nitrate
Ions: Na+ and NO3-. The charges balance one to one, so no brackets are needed: NaNO3.
Potassium carbonate
Ions: K+ and CO32-. Two potassium ions are needed for each carbonate ion: K2CO3. There is only one carbonate ion, so it needs no brackets.
Ammonium phosphate
Ions: NH4+ and PO43-. Three ammonium ions are needed, and since ammonium is polyatomic it takes brackets: (NH4)3PO4.
Two more to test yourself on
Calcium hydroxide: Ca2+ with OH- needs two hydroxides, so Ca(OH)2. Aluminium sulfate: Al3+ with SO42- needs two aluminium ions and three sulfates, so Al2(SO4)3.
Common mistakes to avoid
- Capital letters in the wrong place. CO is carbon monoxide, Co is cobalt, and CoO is cobalt(II) oxide. Getting this wrong changes the substance entirely.
- Forgetting brackets. Mg(NO3)2 is magnesium nitrate; MgNO3 has the wrong charge balance and MgNO32 is nonsense.
- Changing a formula to balance an equation. Once a formula is correct it is fixed. You balance equations by putting big numbers in front, never by editing subscripts.
- Writing the subscript before the symbol. The number always goes after the symbol it applies to.
- Leaving a subscript of 1 in. Write NaCl, not Na1Cl1.
- Not simplifying. The formula of an ionic compound must be the simplest whole-number ratio, so magnesium oxide is MgO and never Mg2O2.
Practice set
- Potassium bromide
- Aluminium chloride
- Calcium nitride
- Iron(III) oxide
- Sodium sulfate
- Ammonium carbonate
- Barium hydroxide
- Copper(II) nitrate
Answers: 1. KBr 2. AlCl3 3. Ca3N2 4. Fe2O3 5. Na2SO4 6. (NH4)2CO3 7. Ba(OH)2 8. Cu(NO3)2
Formulae of the ionic compounds
In some cases, the chemical formula does not represent a molecule. Table salt, sodium chloride, is an example. There are no separate molecules in solid sodium chloride at all.
It is an ionic lattice made up of Na+ and Cl- ions arranged alternately, and it stretches on for millions of ions in every direction. Because the Na+ and Cl- ions are present in a 1:1 ratio, the formula is written NaCl. The formula of an ionic compound is therefore a ratio, not a count of atoms in a particle – which is exactly why it must always be simplified to its lowest terms.
Exam tips
- Always finish by checking that the charges cancel to zero. It takes five seconds and catches almost every slip.
- Write the positive ion first, then the negative ion, in every ionic formula.
- Treat a polyatomic ion as one unbreakable unit. Never split sulfate into S and O to make the numbers work.
- Read the Roman numeral. Iron(II) chloride is FeCl2; iron(III) chloride is FeCl3.
- Do not change subscripts when balancing an equation – that changes the chemical. Adjust only the large numbers in front of each formula.
- Remember the seven elements that exist as diatomic molecules: H2, N2, O2, F2, Cl2, Br2 and I2.
Frequently asked questions about writing chemical formulae
How do you write a chemical formula step by step?
Write the positive ion first with its charge, then the negative ion with its charge. Swap the size of each charge to become the subscript of the other ion, drop any subscript of 1, and simplify to the lowest whole-number ratio. Finally check that the positive and negative charges cancel.
What is valency in chemistry?
Valency is the combining power of an element: the number of electrons its atom loses, gains or shares when forming a compound. For main-group elements it is the group number for groups 1 to 4, and 8 minus the group number for groups 5 to 7.
How do you know the charge on an ion?
For main-group elements, read it from the periodic table group. Group 1 forms 1+ ions, group 2 forms 2+, group 3 forms 3+, group 5 forms 3−, group 6 forms 2− and group 7 forms 1−. Transition metals must be learned or read from the Roman numeral in the name.
When do you use brackets in a chemical formula?
Only when you need more than one polyatomic ion. Magnesium nitrate needs two nitrate ions, so it is written Mg(NO3)2. If only one polyatomic ion is needed, no brackets are used, as in K2CO3.
What does the small number in a chemical formula mean?
It is a subscript, and it gives the number of atoms of the symbol immediately before it. In H2SO4 there are two hydrogen atoms, one sulfur atom and four oxygen atoms. A subscript outside a bracket multiplies everything inside the bracket.
What is a polyatomic ion?
A group of atoms covalently bonded together that carries one overall charge and behaves as a single ion. Common examples are nitrate NO3-, sulfate SO42-, carbonate CO32-, hydroxide OH- and ammonium NH4+.
Why is sodium chloride written NaCl and not Na2Cl2?
Because solid sodium chloride is a giant lattice, not separate molecules, so the formula shows the simplest ratio of ions rather than a count of atoms in one particle. The ions are present in a 1:1 ratio, so NaCl is the correct formula.
What is the difference between CO and Co?
CO is carbon monoxide, a compound of carbon and oxygen. Co is cobalt, a single element. Element symbols use a capital first letter and a lower-case second letter, so a stray capital changes the meaning completely.
Can you change a formula to balance an equation?
No. A correct formula is fixed by the charges on the ions. Equations are balanced only by placing large numbers in front of each formula, never by altering the subscripts inside one.



