Forsyth-Edwards Notation (FEN) is a way to describe the situation in the middle of a chess game. It records all the information necessary to restart the game from a particular position. This is useful for adjourning a game to resume later or for conveying chess problem positions without a diagram.
Forsyth-Edwards Notation is based on a system developed by the Scottish newspaper journalist David Forsyth. Forsyth's system became popular among 19th century chess players. Steven Edwards extended Forsyth's system to support its use by computers.
Nowadays there are variants of chess, such as Fischer Random Chess, where the initial position is not necessarily the traditional initial position. Since Forsyth-Edwards Notation can be used to define non-standard initial positions, it has become an integral part of the Portable Game Notation system of chess notation.
Forsyth-Edwards Notation does not record the move history, just the current position. Therefore it doesn't present sufficient information to decide on draws by threefold repetition. For that, a different format (such as Extended Position Description) is needed.
A Forsyth-Edwards Notation "record" defines a particular game position, all in one line of text, and using only common printable characters. (A text file with only FEN data records should have the file extension ".fen".)
A FEN record begins by showing the location of all the pieces on the chessboard. White pieces are designated by upper-case letters ("KQRBNP"); black pieces are designated by lowercase ("kqrbnp"). Each rank is described, starting with rank 8 and ending with rank 1. The ranks are separated by a "/" character. Within each rank, the contents of each square are described (from file 'a' through file 'h'). Empty squares are represented by a number (from 1 to 8) that shows how many successive squares are empty.
Here is the first part of the Forsyth-Edwards Notation record for the standard chess starting position:
Here is the first part of the FEN record after white opens with 1. e4:
The second part of the Forsyth-Edwards Notation record is either a "w" (meaning white moves next) or a "b" (meaning black moves next). The second part of the FEN record is separated from the first part by a space.
The third part of the Forsyth-Edwards Notation record indicates castling availability. It consists of one or more of the following letters: "K" (white can castle king-side), "Q" (white can castle queen-side), "k" (black can castle king-side), "q" (black can castle queen-side); or else "-" if neither side can castle. The third part of the FEN record is separated from the second part by a space.
The fourth part of the Forsyth-Edwards Notation record shows whether an en passant capture would be allowed. If a pawn has just made a 2-square move, the destination square (in algebraic notation) of the move that would capture it is recorded. If not, "-" is recorded. (If a pawn has just made a 2-square move, the destination square is the position "behind" the pawn.) The fourth part of the FEN record is separated from the third part by a space.
The fifth part of the FEN record shows the number of half-moves since the last pawn advance or capture. This is used to determine if a draw can be claimed under the fifty move rule. The fifth part of the FEN record is separated from the fourth part by a space.
The sixth and final part of the FEN record is the number of the current move. It starts at 1, and is incremented after each black move. The sixth part of the FEN record is separated from the fifth part by a space.
Here is the FEN for the standard chess starting position:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Here is the FEN after the move 1. e4:
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
And then after 1. ... c5:
rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2
And then after 2. Nf3:
rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2