Chemical Equation Balancer

Balance chemical equations using matrix nullspace.

Science Auto-balance Verified
Rate this calculator · 4.5 (2)

Equation Balancer

Matrix solver · per-element verification

Instructions — Chemical Equation Balancer

Type a chemical equation using any of these arrow styles: ->, , or =.

  1. Type the equation with reactants on the left and products on the right, separated by an arrow.
  2. Use plus signs between species: CH4 + O2 -> CO2 + H2O.
  3. Use parentheses for groups: Ca(OH)2, Al2(SO4)3.
  4. Hit a quick-pick to load a classic example, then read the balanced form and the per-element verification.

Note: the solver uses matrix elimination over rational numbers and returns the smallest positive-integer coefficients. Complex redox reactions in acidic or basic media may need manual half-reaction balancing first.

Formulas

Every chemical equation must obey conservation of mass: the count of each element on both sides must match.

The matrix form: $$ \mathbf{A} \cdot \mathbf{c} = \mathbf{0} $$ where $\mathbf{A}$ is the composition matrix (rows = elements, columns = species, reactants positive, products negative) and $\mathbf{c}$ is the coefficient vector.

Balanced condition (per element E): $$ \sum_{\text{reactants}} n_E^{(i)} c_i = \sum_{\text{products}} n_E^{(j)} c_j $$

Solving $\mathbf{A} \cdot \mathbf{c} = \mathbf{0}$ gives a one-dimensional null space for normal equations. The solver normalizes to integers using the LCM of denominators, then divides by the GCD to reach the smallest positive integers.

Reference

TypePatternExample (balanced)
CombinationA + B → AB2 Na + Cl2 → 2 NaCl
DecompositionAB → A + B2 H2O2 → 2 H2O + O2
Single replacementA + BC → AC + BZn + 2 HCl → ZnCl2 + H2
Double replacementAB + CD → AD + CBAgNO3 + NaCl → AgCl + NaNO3
CombustionCxHy + O2 → CO2 + H2OCH4 + 2 O2 → CO2 + 2 H2O

The rule that catches most students: only the coefficients change. The subscripts inside a formula (the "2" in H2O) are part of the compound and may not be edited — doing so changes the substance.

Article — Chemical Equation Balancer

Chemical Equation Balancer: Automatic Coefficients for Any Reaction

A balanced chemical equation has equal numbers of each element on both sides, satisfying the law of conservation of mass. Antoine Lavoisier established conservation of mass in the 1770s; modern balancing uses either inspection or matrix nullspace methods to find the smallest positive integer coefficients. This chemical equation balancer parses the formula, builds a composition matrix, solves A · c = 0, and returns the integer solution.

For straightforward reactions — combustion, single-replacement, simple combination — the balancer returns the answer in a fraction of a second. Complex redox equations in acidic or basic media sometimes need manual half-reaction balancing first.

What balancing a chemical equation means

A chemical equation describes a reaction: reactants on the left, products on the right, separated by an arrow. The unbalanced equation lists the molecules involved but does not yet specify proportions. Balancing assigns a coefficient (a number in front of each formula) so that every element has the same total count on both sides.

Coefficients represent the relative number of molecules — or moles — that participate. By convention they are the smallest positive integers that satisfy mass conservation. A leading 1 is omitted by convention, just as in algebra.

Why chemical equations must be balanced

Conservation of mass is a fundamental physical law: in a closed system, atoms are neither created nor destroyed. Every atom that goes into a reaction must come out, possibly rearranged into different molecules but never disappearing.

Balanced equations enable stoichiometry — calculating how much product forms from a given amount of reactant, or how much of one reactant is needed to consume a specific amount of another. Without coefficients, the equation describes only the qualitative chemistry; with them, it becomes quantitative.

Did you know

Antoine Lavoisier proved conservation of mass in the early 1770s by burning metals in sealed glass vessels and weighing everything before and after. The metals gained weight, but the surrounding air lost exactly that same amount. This killed the phlogiston theory and established chemistry as a quantitative science. Lavoisier was guillotined during the French Revolution in 1794, two decades after his foundational discoveries; he is still called the father of modern chemistry.

Balancing chemical equations by inspection

For simple reactions, balance by inspection — trial and error with strategic ordering:

  1. Write the unbalanced equation with correct molecular formulas.
  2. Count each element on both sides.
  3. Start with the most complex molecule and the element appearing in the fewest places.
  4. Add coefficients to balance that element.
  5. Move to the next element. Save hydrogen and oxygen for last; they often appear in multiple compounds.
  6. Recount everything to verify the balance.

Example: Fe + O2 → Fe2O3. Fe: 1 on left, 2 on right; place 2 in front of Fe. Now Fe is balanced at 2. Oxygen: 2 on left, 3 on right; the LCM is 6, so use 3 O2 on the left and 2 Fe2O3 on the right. That now requires 4 Fe on the left. Final: 4 Fe + 3 O2 → 2 Fe2O3.

Balancing chemical equations by matrix method

For anything more complex than four or five species, the matrix method is reliable and mechanical. Build a composition matrix A: rows are elements, columns are molecules. Cell Aij holds the count of element i in molecule j, with reactants positive and products negative.

The balanced condition is A · c = 0, where c is the vector of coefficients. Solve this linear system — usually it has a one-dimensional null space. The solution is normalized to the smallest positive integers by clearing fractions (multiply by the LCM of denominators) and dividing by the GCD.

Matrix balancing
A · c = 0 conservation matrix equation
solve null space Gauss-Jordan over rationals
scale to integers LCM up, GCD down

Common chemical equation types

Most chemistry-class reactions fall into a handful of categories. The balancer handles all of them when written with explicit molecular formulas.

  • Combination (synthesis): A + B → AB. Example: 2 H2 + O2 → 2 H2O
  • Decomposition: AB → A + B. Example: 2 H2O2 → 2 H2O + O2
  • Single replacement: A + BC → AC + B. Example: Zn + 2 HCl → ZnCl2 + H2
  • Double replacement: AB + CD → AD + CB. Example: AgNO3 + NaCl → AgCl + NaNO3
  • Combustion: CxHy + O2 → CO2 + H2O. Example: CH4 + 2 O2 → CO2 + 2 H2O
  • Acid-base neutralization: acid + base → salt + water. Example: HCl + NaOH → NaCl + H2O

Balancing redox equations

Complex redox needs the half-reaction method

Redox reactions in acidic or basic solution often require adding H+, OH, electrons, and water. The automatic balancer handles atom conservation but not charge conservation in those settings. For complex redox, balance each half-reaction manually (oxidation and reduction separately), combine them so electrons cancel, then enter the result here to verify.

The half-reaction method works as follows: split into oxidation and reduction halves. Balance atoms other than O and H first. Balance O by adding H2O. Balance H by adding H+ (acidic) or both H+ and OH (basic). Balance charge with electrons. Multiply each half by a factor so the electrons match, then add them together. The electrons cancel, leaving the balanced overall equation.

Example: MnO4 + Fe2+ → Mn2+ + Fe3+ in acid. Final balanced: MnO4 + 5 Fe2+ + 8 H+ → Mn2+ + 5 Fe3+ + 4 H2O.

Limitations of automatic balancing

This balancer handles atom conservation. It does not check chemical reasonableness; if you enter an impossible reaction, it may return coefficients that satisfy mass balance but describe something that never actually happens. It also cannot infer missing species: if your equation forgets to include water as a product, the balancer cannot add it for you.

Equations involving phase labels (g), (l), (s), (aq), state symbols, or reaction arrows with conditions written above them should have those stripped before entering. Isotope-specific reactions (e.g., balancing nuclear equations) require a different framework that tracks atomic number and mass number, not just element.

Tip

If the balancer fails, simplify. Strip parenthetical state labels, write polyatomic ions as their full atomic composition, and verify all subscripts. Most failures are typos. If a complex redox refuses to balance, sketch the half-reactions by hand first.

Balanced equation checklist

Three things to verify on every balanced equation: each element appears the same number of times on both sides; coefficients are the smallest positive integers; and the charge balance (sum of charges) is equal on both sides for ionic equations. The automatic balancer enforces the first two, and the per-element verification table confirms the count.

Once balanced, the equation supports stoichiometric calculations: limiting reactant analysis, theoretical yield, percent yield, mole ratios, and gas-volume relationships under ideal conditions. The chemical equation balancer is the entry point to all of those problems.

FAQ

To satisfy conservation of mass: matter cannot be created or destroyed in a chemical reaction. A balanced equation shows the correct stoichiometric ratios needed to predict how much product forms from given amounts of reactants.
No. Subscripts (like the 2 in H2O) define what the molecule is. Changing them changes the substance: H2O is water, but H2O2 is hydrogen peroxide. Balance equations by changing coefficients in front of the formulas only.
The integers placed in front of chemical formulas to balance an equation. They represent the relative number of molecules (or moles) of each species that participate in the reaction. A balanced equation uses the smallest set of positive integers.
Each row of the matrix represents an element and each column represents a species, with reactants positive and products negative. The number of each element's atoms goes into the cell. Solving the system A·c = 0 by elimination gives the coefficient ratios; scaling to integers gives the balanced form.
Mathematically, any solution can be multiplied by a constant. By convention, chemistry uses the smallest positive integers, which is what this tool returns. If a reaction has multiple independent balanced sets (rare), the equation likely combines two simpler reactions.
Redox reactions in acidic or basic media often require adding H+, OH−, electrons, or water to balance both atoms and charge. The simple matrix solver only handles atom conservation. For complex redox, use the half-reaction method by hand, then enter the combined equation here.
Once the equation is balanced, the coefficients let you compare the moles of each reactant to the stoichiometric ratio. Whichever reactant runs out first — relative to that ratio — is the limiting reactant, and it caps the theoretical yield.
Antoine Lavoisier demonstrated it in the 1770s with careful sealed-vessel combustion experiments. He showed that the mass gained by a metal during combustion exactly equalled the mass lost by the surrounding air, killing the phlogiston theory and launching modern chemistry.