What this balancer does
Type a chemical equation — reactants on the left, products on the
right, separated by an arrow (→ or ->)
— and the balancer returns the smallest set of positive integer
coefficients that make every element's atom count equal on both
sides. It also shows the per-element check so you can verify the
balance by eye.
Unlike trial-and-error, the algorithm is deterministic: for any balanceable equation it returns the unique smallest-integer answer, and for non-balanceable equations it tells you so instead of looping forever.
How it works — the algebraic method
Every compound in the equation gets a coefficient (call them
a, b, c, …). The constraint
that each element must balance on both sides gives one linear
equation per element. So if your equation has n compounds
and k elements, you have k equations in
n unknowns. Writing this as a matrix:
- Each row of the matrix represents one element.
- Each column represents one compound.
- The entry is the number of atoms of that element in that compound — positive for reactants, negative for products.
- The balanced equation is a nontrivial solution to
Ax = 0— i.e. a vector in the matrix's null space.
The balancer solves this via Gaussian elimination with partial pivoting, treats the last unknown as a free variable (= 1), and back-substitutes. The resulting rational coefficients are converted to integers by taking the LCM of fractional denominators, then reduced by the GCD to ensure the answer is in lowest terms.
Worked example: KMnO₄ + HCl → KCl + MnCl₂ + H₂O + Cl₂
Six compounds, four elements (K, Mn, O, H, Cl — five elements, actually). The balancer constructs a 5×6 matrix:
- K: +1 (KMnO₄) − 1 (KCl) → coefficients must satisfy
1a − 1c = 0 - Mn: +1 (KMnO₄) − 1 (MnCl₂) →
1a − 1d = 0 - O: +4 (KMnO₄) − 1 (H₂O) →
4a − 1e = 0 - H: +1 (HCl) − 2 (H₂O) →
1b − 2e = 0 - Cl: +1 (HCl) − 1 (KCl) − 2 (MnCl₂) − 2 (Cl₂) →
1b − 1c − 2d − 2f = 0
Solving this system gives
2 KMnO₄ + 16 HCl → 2 KCl + 2 MnCl₂ + 8 H₂O + 5 Cl₂,
which the atom check then verifies: 2 K on each side, 2 Mn on each
side, 8 O on each side, 16 H on each side, 16 Cl on each side. ✓
What this balancer can and can't do
Can:
- Any equation balanceable from atom counts alone — combustion, double-displacement, precipitation, acid-base neutralization, most synthesis and decomposition reactions.
- Polyatomic ions in parentheses:
Ca₃(PO₄)₂,Al₂(SO₄)₃,Cu(NO₃)₂. - Hydrate notation:
CuSO₄·5H₂O. - Equations with many compounds: the algorithm scales — KMnO₄ + HCl with 6 compounds and 5 elements solves as quickly as H₂ + O₂.
Can't:
- Half-reactions (e.g.
MnO₄⁻ + e⁻ → Mn²⁺) — electron transfer isn't expressed as an atom count. Use the half-reaction method by hand for those. - Incomplete redox equations where the algebraic method admits multiple solutions. The balancer reports "could not balance" in that case.
- Charge balancing for ionic equations (no
+/−charges in formulas). - Net ionic equations as written (spectator ions removed) — balance the molecular form first.
Common errors
Case matters. Co is cobalt, CO is carbon monoxide. NACL won't parse — it has to be NaCl.
Use → or -> between sides. Equal signs work too (A + B = C), but use exactly one separator. Multi-step reactions need to be balanced one step at a time.
If the balancer can't solve it, check the chemistry, not the math. The most common cause is a missing product or reactant. The balancer is honest: if the atom counts can't balance with positive coefficients, the equation as written is wrong.