Skip to main content

Sudoku Solver

Solve any valid 9x9 sudoku grid instantly with a backtracking solver and MCV heuristic.

Written by Golam Rabbani, Founder & Lead Engineer

Enter givens (1–9) in any cell, leave others blank, and press Solve. Uses backtracking with most-constrained-variable selection.

How to use this sudoku solver

  1. Type your given digits (1–9) into the 9×9 grid; leave blank any cells you want the solver to fill.
  2. Press Load Sample if you want a known-difficult puzzle to test the solver instantly.
  3. Press Solve — the algorithm fills every empty cell with a valid digit and shows the new values in blue.
  4. Press Copy Solution to copy the solved 9×9 grid as a plain-text block you can paste into a notes app.
  5. Press Reset to clear the entire board (both your givens and the solver output) for a fresh puzzle.

About this sudoku solver

Sudoku Solver finds the unique solution (or the first valid solution if the puzzle is under-constrained) for any valid 9×9 sudoku grid. The algorithm is recursive backtracking with the most-constrained-variable heuristic: at every step the solver scans the empty cells, lists the digits each one could legally take given the existing rows, columns, and 3×3 boxes, and recurses into the cell with the fewest legal candidates first. That ordering dramatically prunes the search tree compared with naive left-to-right backtracking, so even the standard "World's Hardest Sudoku" finishes in a few milliseconds on a typical phone.

Before solving, the tool validates your givens: if the same digit appears twice in any row, column, or 3×3 box, an error message asks you to fix the conflict instead of running the solver to no end. If you leave the board empty the solver refuses to run — you need at least one given to anchor the puzzle. Solved cells are shown in blue and your original givens stay black so it is easy to see what the solver added. The whole computation happens in your browser; no puzzle data is uploaded.

Worked example: press Load Sample to fill the board with the classic 5/3/_, 6/_/_, _/9/8 opening row pattern. Press Solve. Within a few milliseconds the empty cells fill in: the top row reads 5 3 4 6 7 8 9 1 2, the second row reads 6 7 2 1 9 5 3 4 8, and so on. Original digits stay in black; new digits appear in blue. Press Copy Solution and you get the full 9-by-9 grid as space-separated digits over nine lines, ready to paste into a note. If you instead type two 5s into the same row and press Solve, the tool refuses and shows "Givens conflict — same digit appears twice in a row, column, or 3x3 box."

FAQ

Can it solve every valid 9×9 sudoku?
Yes. Backtracking with MCV is complete — if a solution exists the algorithm will find it; if none exists the tool reports "No solution exists for this board".
Why are some cells in blue and others in black?
Blue cells are the digits the solver added; black cells are the givens you typed. The visual split makes it obvious what was already known versus what was derived.
What happens if I make the puzzle invalid?
If the givens conflict (same digit twice in a row, column, or 3×3 box), the tool refuses to solve and shows an inline error. Fix the conflict and press Solve again.
Does the solver guess or just deduce?
Backtracking is essentially deductive search with branching. On easier puzzles it deduces with no branching; on harder puzzles it tries a candidate, recurses, and rolls back if it hits a contradiction.
Is the puzzle sent to a server?
No. The whole solver runs in your browser. Nothing about your board is uploaded.
Can I edit the solution after solving?
No — once a board is solved, only the original given cells stay editable. Press Reset to start a brand-new puzzle.