Tic-Tac-Toe Solver
The Tic-Tac-Toe Solver takes any position and returns the perfect move — win, loss or draw.
Options
Enter any Tic-Tac-Toe position, pick whose turn it is, and a perfect-play engine highlights the best move and tells you whether it's a win, a loss or a draw. It works as a Tic-Tac-Toe best-move calculator — recreate any board and it names the optimal next move to play. Everything runs in your browser, nothing is uploaded. See how the solver works →
How to Use the Solver
Click a square to cycle it through blank, X and O, and recreate the position on your board. Set whose turn it is, then press Solve. The best move (or moves, if several are equally good) lights up in green, and the message tells you the outcome with perfect play — a forced win, a certain loss, or a draw. Clear empties the board.
How the Solver Works
Tic-Tac-Toe is small enough to solve exactly. The engine uses minimax: it plays out every possible continuation to the end of the game, assuming both sides play perfectly, and scores each — a win, a loss or a draw — preferring faster wins and slower losses. The move that leads to the best guaranteed result is the answer. Because it searches the entire game tree, the advice is provably optimal. It all runs on your device.
The verdicts are exact, not estimated: the engine enumerates all 5,478 reachable positions and 255,168 possible games, and that full enumeration is published as an open benchmark dataset so anyone can verify the counts.
Frequently Asked Questions
How do I enter a position?
Does it play perfectly?
Can Tic-Tac-Toe always be won?
What do the highlighted squares mean?
Is anything uploaded?
Is this a Tic-Tac-Toe best move calculator?
Related Solvers & Games
Prefer to play? Take on the unbeatable AI Tic-Tac-Toe. Solving other games? Try the Connect 4 Solver, the Sudoku Solver or the 2048 Solver, or browse all AI solvers & analyzers.
New to the theory? TicToe.org's guide on how to never lose at tic-tac-toe walks through the key positions this solver evaluates.
Add This Tic-Tac-Toe Solver to Your Website
Put the Tic-Tac-Toe Solver on your own page — free, no sign-up, no watermark. It runs entirely in your visitors' browsers. Copy the snippet and paste it into your page's HTML.