Castling in chess
Stockfish 16.1 · runs in your browserPlay O-O. White's king reaches g1 and the rook reaches f1 in one move.
Play on the board, or use Type a move below it.
Play a move by typing it, like e4, Nf3 or e7e8q, then press Enter.
Commentary
Move a piece, paste a position, or press the button.
Best move
Castling moves the king two squares toward a rook and the rook to the square the king crossed. Neither piece may have moved, the gap must be clear, and the king cannot castle out of, through or into check.
Try the moves
Choose an example, play the suggested move, then reset to compare another legal move.
Castling is one move with two pieces. For White's kingside castle, the king travels from e1 to g1 and the rook from h1 to f1; queenside puts the king on c1 and the a1 rook on d1. Black uses the same pattern on the eighth rank. Select each legal example and watch both pieces arrive. The king crosses one square and lands on the next. Moving only the rook, or moving the king just one square, is an ordinary move rather than castling.
There are permanent and temporary reasons the board may refuse a castle. Once the king moves, castling on either side is lost, even if it returns home. A rook that has moved loses the right on its own side. A piece between king and rook blocks the path for now. The king cannot start in check, cross an attacked square, or land in check. An attacked rook, by itself, does not prevent castling; the rule tests the king's squares.
Use the blocked example to test the tempting move. Black's bishop on a6 attacks f1, the square White's king would cross. Drag the king from e1 to g1: the board refuses the castle, although g1 itself looks open. Play Kd2 as a legal king move; that choice gives up White's castling right for the rest of this game. In your own position, inspect e1, f1 and g1 for attacks before you try O-O, and check that the relevant rook has never moved.
Rules and examples
FIDE Laws of Chess, Articles 3.8.2.1 and 3.8.2.2, separate lost rights from temporary blocks.
Rules: FIDE Laws of Chess, effective 1 January 2023. https://handbook.fide.com/chapter/E012023
Rule replay: python-chess 1.11.2 (GPL-3.0-or-later). The shared browser engine retains its Stockfish GPL-3.0 notice. No engine score is claimed by these demonstrations.
Read the rulesA move on the board
r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4
r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQ1RK1 b kq - 5 4
- O-OWhite's king reaches g1 and the rook reaches f1 in one move.
White's king reaches g1 and the rook reaches f1 in one move.
Original teaching example replayed with python-chess 1.11.2, 2026-10-23.
Analysis runs on Stockfish 16.1 in your browser, compiled to WebAssembly by stockfish.js. Stockfish is free software under the GNU General Public License v3; its source code is on GitHub.
