↑↓ to move ↵ to open Esc to close Browse all tools

Tic Tac Toe

Get three in a row before the other side does. Play the computer on three levels or a friend on the same device.

Play tic tac toe

Level
You play
First move

Use the arrow keys to move between squares and Enter or Space to play.

You
0
Computer
0
Draws
0
Counts the games in this tab only. A game left before it ends does not count.

Runs in your browser. Moves and scores stay on this device and are not saved.

Free printablePrintable Score SheetPlayers across, rounds down, with totals, for any card or board game.

Tic Tac Toe by Freebiefy, free online tools · Privacy · Legal notice

Embed this tool on your site

Paste this code into your page. The tool runs in the visitor's browser, free and without signup. The height adjusts to the content. All tools you can embed

Tic tac toe rules

Tic tac toe is played on a grid of three by three squares. One player uses X, the other O. The players take turns, and each turn puts one mark in an empty square. The first player to fill a whole row, a whole column or one of the two diagonals with their own mark wins. When all nine squares are full and nobody has a line, the game is a draw.

There is no fixed rule about who starts. A common convention is that X goes first, which is why this page starts with X unless you change it. Since the player who moves first can place five marks and the other only four, it is fair to swap the starting player between games. The Take turns setting does that for you.

Easy, medium and hard

The three levels follow simple rules, so you know what you are playing against.

  • Easy picks any free square at random. It is a good level for young children and for learning how lines form.
  • Medium first checks whether it can complete a line and does so. If not, it checks whether you are about to complete one and blocks it. Otherwise it plays a random square. It does not see forks, so you can beat it by building two threats at once.
  • Hard uses a minimax search. For every free square it plays out every possible rest of the game, assumes that you answer with your best move each time, and keeps only the moves with the best result. When several moves are equally good, it picks one of them at random, so the games do not all look alike. A quick win scores higher than a slow one, so it finishes when it can.

Why perfect play always ends in a draw

Tic tac toe is small enough to check completely. We counted every possible game with a short program that plays out all move orders, with X moving first, and stops each game as soon as someone completes a line or the board is full. These are the computed totals:

What was countedNumber
Possible games (different move orders)255,168
Games won by X, the first player131,184
Games won by O77,904
Games that end in a draw46,080
Different final boards958
Final boards when rotations and mirror images count as one138

Of those 138 final boards, 91 are wins for X, 44 are wins for O and 3 are draws. More games are won by X because the first player has an extra mark. Yet when both sides look ahead and never make a losing move, every game ends in a draw. The same program shows that the value of the empty board is a draw for both players, and that no opening square changes that. This is why the hard level cannot be beaten: it never makes a mistake, so the best you can reach is a draw.

Strategy tips

A simple priority list plays well. On every turn, take the first rule that applies:

  1. Win: complete your own line.
  2. Block: stop the other player's two in a row.
  3. Fork: make a move that creates two threats at once, so only one can be blocked.
  4. Block a fork: stop the other player from setting one up.
  5. Take the center.
  6. Take the corner opposite the other player's corner.
  7. Take any empty corner.
  8. Take any empty side square.

The most common beginner mistake is the answer to a corner opening. When X starts in a corner, the center is the only reply for O that does not lose. Our engine confirms this: against X in a corner, every square except the center leads to a forced win for X.

A worked example

X starts in the top left corner (row 1, column 1). O answers in the top middle square (row 1, column 2), which looks harmless. X takes the center. Now X threatens the diagonal from top left to bottom right, so O must block in the bottom right corner. X then plays the bottom left corner (row 3, column 1). That one move makes two threats: column 1 needs only row 2, and the diagonal from top right needs only the top right corner. O can block one of them, and X completes the other. Try it on easy or medium as X to see the fork, then try the same line against hard as O to see how the computer avoids it.

How to play tic tac toe online

  1. 1Choose Against the computer or Two players. Against the computer, pick a level and whether you play X or O.
  2. 2Pick who makes the first move, or Take turns to swap the starting player after every game.
  3. 3Tap a square to place your mark, or use the arrow keys and Enter. The status line under the board says whose turn it is.
  4. 4When a line is complete, the three squares are highlighted and the score updates. Press New game for the next round.

Frequently asked questions

Can I beat the computer on hard?

No. On hard the computer searches every possible continuation of the game and only plays moves that do not lose. We tested this by letting a program play every possible sequence of moves against it, as X and as O, with either side starting. The human side never won. The best you can do is a draw, and the computer wins every game where you make a mistake it can use.

What is the difference between easy, medium and hard?

Easy picks a random free square every time. Medium completes a line when it can, blocks your line when you have two in a row, and otherwise plays a random square, so it can still walk into a fork. Hard looks ahead to the end of the game and never makes a losing move.

Who goes first?

You decide. In the First move setting pick yourself, the computer, or Take turns, which swaps the starting player after every game. In two-player mode pick X, O or Take turns. A common convention is that X starts, but there is no fixed rule about it.

How do two players play on one device?

Pick Two players. The players share the screen and take turns tapping a square. The status line under the board always says whose turn it is, and the score counts wins for X, wins for O and draws.

Can I play with a keyboard or a screen reader?

Yes. The board is a set of nine buttons. Press Tab to reach it, move between squares with the arrow keys, and press Enter or Space to place your mark. Each square has a label such as "Row 1, column 2, empty", and the status line announces every move and the result.

Is my score saved?

The score counts the games you play in this tab, separately for games against the computer and for two-player games. It is not stored anywhere, so it starts at zero when you reload the page. Reset score sets it to zero right away.