Chemical equation balancer

Type any unbalanced chemical reaction below and get the smallest-integer balanced form. Handles parentheses, polyatomic ions, and arbitrary numbers of reactants and products.

Equation balancer

Balanced equation

How it works

Every balanced chemical equation satisfies one rule: the count of each element must be the same on both sides. The balancer turns this rule into linear algebra:

  1. Parse each compound into its element-count vector (e.g., H2O → {H: 2, O: 1}).
  2. Build a matrix where each row is an element and each column is a compound. Reactants get a + sign, products get a sign.
  3. Find the null space of this matrix using Gaussian elimination — the vector x such that M·x = 0. That vector is the coefficient set.
  4. Scale to the smallest positive integers by multiplying through the LCM of denominators and dividing by the GCD.

This works for any equation that has a unique balance ratio. Equations with multiple independent solutions (rare in textbook chemistry) return the first basis vector.

Syntax

You writeMeaning
H2OTwo hydrogen, one oxygen
Ca(OH)2One calcium, two hydroxide groups (= 2 O, 2 H)
Al2(SO4)3Two aluminium, three sulfate groups (= 3 S, 12 O)
K3Fe(CN)6Three potassium, one iron, six cyanide groups
+ or = or Separator between compounds / sides

Element symbols must be properly capitalised: Co is cobalt, CO is carbon monoxide, co is invalid. Coefficients you type yourself are ignored — the balancer determines them.

Worked example

Combust propane: C3H8 + O2 = CO2 + H2O

  1. Element vectors: C3H8 → {C:3, H:8}; O2 → {O:2}; CO2 → {C:1, O:2}; H2O → {H:2, O:1}
  2. Matrix (rows: C, H, O; columns: C3H8, O2, −CO2, −H2O):
      3  0 −1  0
      8  0  0 −2
      0  2 −2 −1
  3. Solving gives the coefficient vector [1, 5, 3, 4] — already in smallest integers.
  4. Result: 1 C₃H₈ + 5 O₂ → 3 CO₂ + 4 H₂O

FAQ

Why does it not balance my equation?

Most often: a typo in element capitalisation (nh3 won't parse — use NH3), a missing side (you typed only reactants), or a chemically impossible equation (atoms can't be conserved with the compounds you wrote). The error message points at which step failed.

Can it balance redox / ionic equations?

It balances atom counts, which is what most introductory and high-school problems want. For redox equations where charge balance also matters, you may need to add electrons or H⁺/OH⁻ manually after the atom balance — that's beyond pure linear-algebra balancing.

Why integer coefficients and not decimals?

Chemistry uses integer stoichiometric coefficients by convention (one molecule reacts with another molecule, not 0.5 of one). The tool always scales to the smallest positive integers using the LCM of denominators.

Related calculators