Tic-Tac-Toe Solver
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. Everything runs in your browser, nothing is uploaded.
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.
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?
Related Solvers & Games
Prefer to play? Take on the unbeatable AI Tic-Tac-Toe. Solving other games? Try the Connect 4 Solver or the Sudoku 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.