What Is a Compound Formula in Chemistry?

A compound formula is a shorthand way of representing a chemical compound using element symbols and numbers. For example, H₂O is the compound formula for water: the H stands for hydrogen, the O for oxygen, and the small “2” after the H tells you there are two hydrogen atoms for every one oxygen atom. Every chemical compound has a formula like this, and once you understand how to read it, you can instantly see what a substance is made of and in what proportions.

How to Read a Compound Formula

A compound formula has two main components: element symbols and subscripts. The element symbols are one- or two-letter abbreviations from the periodic table (H for hydrogen, O for oxygen, Ca for calcium, Na for sodium). The subscripts are the small numbers written to the lower right of each symbol, indicating how many atoms of that element are present. If no subscript appears, it means there’s exactly one atom.

Take carbon dioxide: CO₂. The C represents one carbon atom (no subscript, so the count is one). The O₂ means two oxygen atoms. Put together, one molecule of carbon dioxide contains one carbon atom bonded to two oxygen atoms. Glucose, C₆H₁₂O₆, contains 6 carbon atoms, 12 hydrogen atoms, and 6 oxygen atoms per molecule.

Why Formulas Are Always the Same

A compound formula isn’t arbitrary. It reflects a principle called the law of constant composition: in any given chemical compound, the elements always combine in the same fixed ratio. Every molecule of water on Earth is two hydrogens and one oxygen. If you measured the mass, you’d find that 94% of a water molecule’s weight comes from oxygen and 6% from hydrogen, and this holds true whether the water came from a glacier or a kitchen faucet.

This also means that different ratios create entirely different substances. Hydrogen and oxygen can combine as H₂O (water) or H₂O₂ (hydrogen peroxide). The formulas look similar, but one extra oxygen atom changes the compound completely.

Types of Compound Formulas

There are three main types of compound formulas, and each one tells you something slightly different.

A molecular formula shows the exact number of each type of atom in a single molecule. C₆H₁₂O₆ for glucose is a molecular formula because it tells you precisely how many atoms are in one molecule. This is the most common type you’ll encounter.

An empirical formula gives only the simplest whole-number ratio of atoms. Glucose’s empirical formula is CH₂O, meaning carbon, hydrogen, and oxygen are present in a 1:2:1 ratio. The empirical formula is useful when you know the proportions of elements in a compound but haven’t yet determined the actual molecule size. Titanium dioxide, used as a white pigment in paint and sunscreen, has the empirical formula TiO₂, which also happens to be its molecular formula.

A structural formula includes the same atom information but also shows how atoms are connected to each other using lines to represent bonds. This matters because two compounds can share the same molecular formula but have completely different structures and properties. Structural formulas are especially important in organic chemistry, where carbon-based molecules can be arranged in many configurations.

Parentheses and Complex Notation

Some compound formulas use parentheses to group atoms together. Calcium hydroxide, for example, is written as Ca(OH)₂. The parentheses around OH tell you that the entire OH group appears twice. So this compound contains one calcium atom, two oxygen atoms, and two hydrogen atoms. To count atoms when parentheses are involved, multiply everything inside the parentheses by the subscript outside.

Another notation you might see is the centered dot, used for hydrated compounds. These are ionic compounds that have water molecules physically incorporated into their crystal structure. Barium hydroxide octahydrate is written as Ba(OH)₂·8H₂O, meaning each unit of barium hydroxide is associated with eight water molecules. The dot separates the main compound from the water portion.

Ionic Compounds vs. Molecular Compounds

Not all compound formulas describe molecules. Ionic compounds, like table salt (NaCl), don’t exist as individual molecules. Instead, they form large repeating crystal lattices where sodium and chloride ions alternate in a three-dimensional grid. The formula NaCl represents the smallest ratio of ions in that lattice, called a “formula unit,” not a standalone molecule. For this reason, the formulas of many ionic compounds are technically empirical formulas showing the simplest ratio of the ions involved.

Covalent (molecular) compounds, on the other hand, do exist as discrete molecules. Water really does travel in packages of two hydrogen atoms and one oxygen atom. So H₂O is both a molecular formula and an accurate description of a single, independent unit.

Coefficients vs. Subscripts

In chemical equations, you’ll sometimes see a number placed in front of a formula, like 2H₂O. That leading number is a coefficient, and it means something different from a subscript. The subscript (the small 2 after H) tells you how many atoms are in one molecule. The coefficient (the large 2 in front) tells you how many molecules are present. So 2H₂O means two molecules of water, containing a total of four hydrogen atoms and two oxygen atoms.

This distinction matters because subscripts are fixed properties of a compound. You can’t change them without creating a different substance. Coefficients, on the other hand, are adjusted freely when balancing chemical equations to ensure the same number of each atom appears on both sides of a reaction.

How Compound Formulas Are Determined

Chemists figure out a compound’s formula by measuring what percentage of its mass comes from each element, then converting those percentages into atom ratios. The process works like this: assume you have 100 grams of the compound, so each percentage becomes a mass in grams. Then divide each element’s mass by its atomic weight to find how many moles of each element are present. Finally, divide all the results by the smallest number to get the simplest whole-number ratio. That ratio gives you the empirical formula.

If the ratios don’t come out to clean whole numbers, you multiply them all by the same factor to clear the fractions. For instance, a ratio of 2.33 to 1.67 to 1 translates to 7:5:3 after multiplying everything by 3. To get from the empirical formula to the molecular formula, you need one additional piece of information: the compound’s actual molecular weight. Dividing the molecular weight by the empirical formula weight tells you how many times the empirical unit repeats in the real molecule.