One Input, One Bounded Search
The balancer shows a single text box and one button. Behind them runs a bounded brute-force search that tries integer coefficients in ascending order until every element count matches on both sides. That design choice creates hard limits, and this article documents each limit with the exact outputs our code produces.
The integer search returns whole number coefficients directly. It needs no fraction clearing step, because it never considers fractions at all. The cost is that some correct balances sit outside the search range, and you will see exactly which ones below.
What the Parser Reads
The parser reads element symbols only. Its pattern takes one uppercase letter, optionally one lowercase letter, then an optional count. Fe2O3 parses as Fe 2 and O 3. H2O parses as H 2 and O 1.
The parser skips everything else, including parentheses and hydrate dots. In our verification run, Ca(OH)2 parsed as Ca 1, O 1, and H 1, and CuSO4.5H2O parsed as Cu 1, S 1, O 5, and H 2. Both counts are wrong. Expand grouped and hydrated formulas by hand before you enter them.
Symbols are case sensitive, and the second letter matters. CO parses as carbon and oxygen, while Co parses as cobalt. A lowercase first letter never matches, which is one quiet way an element ends up missing from the count.
The Two Coefficient Caps
The algorithm walks compounds left to right and tries each coefficient from 1 upward. Two caps bound the search.
- Up to four compounds: coefficients 1 through 10, at most 10,000 combinations.
- Five or six compounds: coefficients 1 through 5, at most 15,625 combinations.
- Seven or more compounds: rejected before any search starts.
The final check also fails when an element totals zero on the left side. A mistyped symbol that appears on the products side only therefore produces an error. The first solution found is returned, and coefficients equal to 1 are hidden in the output so the result reads like a textbook equation.
The caps exist because the search space grows as a power. Ten allowed coefficients across six compounds would mean up to 1,000,000 combinations, against 15,625 with the cap of 5. The caps keep every search instant, at the price you see in the next section.
The input box arrives prefilled with H2 + O2 = H2O. Balance it once to see the output format before you clear it for your own reaction.
Equations That Balance, With Verified Outputs
We ran the algorithm on three standard classroom equations. These outputs are the actual results.
Input H2 + O2 = H2O returns 2H2 + O2 = 2H2O. Input C3H8 + O2 = CO2 + H2O returns C3H8 + 5O2 = 3CO2 + 4H2O. Input Fe + O2 = Fe2O3 returns 4Fe + 3O2 = 2Fe2O3.
Each result preserves your subscripts and changes coefficients only. Verify any result by recounting atoms on both sides, which takes under a minute for equations of this size.
Two Equations the Tool Rejects
Octane combustion needs a coefficient of 25 on O2.
C8H18 + O2 = CO2 + H2O
The standard balance is 2C8H18 + 25O2 = 16CO2 + 18H2O. This equation has four compounds, so the cap is 10. The search never reaches 25 and reports the error message instead of a wrong answer.
The permanganate and hydrochloric acid reaction has six compounds, so the cap drops to 5.
KMnO4 + HCl = KCl + MnCl2 + H2O + Cl2
Its standard balance starts 2KMnO4 + 16HCl. Sixteen exceeds 5, so this equation also fails. Both failures print the same message, which reads could not balance, check format or complexity. Failing loudly is the correct behavior here, because a partial coefficient set would look like a balanced equation at a glance.
Input Rules
1. Use exactly one equals sign. Zero or two equals signs trigger the error path.
2. Separate compounds with a plus sign.
3. Write counts immediately after their symbols. Spaces inside a formula break the count.
4. Expand parentheses before entry. Enter Ca(OH)2 as CaO2H2.
5. Keep the equation at six compounds or fewer.
6. Confirm every element appears on both sides.
Honest Downsides
The caps exclude real textbook equations, as the two verified failures show. Parenthesis groups and hydrates are unsupported, so you must expand them yourself and check the expansion. Charges are not modeled, which puts ionic half equations with electrons out of scope. Electron symbols never parse, because a symbol must start with an uppercase letter. Reaction arrows are unsupported, so use the equals sign even when your worksheet prints an arrow.
Checklist Before You Trust a Result
- [ ] Recount each element on both sides of the output yourself.
- [ ] Confirm your compound count and the cap that applies to it.
- [ ] Confirm your formulas contained no parentheses or dots.
- [ ] Confirm every element appears on both sides of your input.
- [ ] Confirm the output kept your subscripts unchanged.
If the tool rejects an equation you expected it to solve, send us the equation and its standard balance. We track which cap causes each reported failure, and repeated failures on real assignments are the strongest case for raising the limits or switching to a matrix solver. Test your own reaction on the [chemical equation balancer](/en/chemical-equation-balancer).