dojotrades.com

Reading a FEN string, one field at a time

FEN is a line of text that describes a single chess position. It looks like a jumble of letters, digits and slashes, yet each part has one clear job. The initials stand for Forsyth-Edwards Notation.

You will learn what the six fields record, how to picture the board from the first one, what the later fields add that a drawing cannot show and how to read a complete string without guessing.

Six fields separated by spaces

A full FEN has six fields in a fixed order, with a space between each one and the next. This is the string for the start of a game.

The starting position

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

The six fields of that string
FieldNameHereWhat it records
1piece placementrnbqkbnr/ ... /RNBQKBNRwhere each piece stands
2side to movewwhose turn it is
3castling rightsKQkqwhich castling rights remain
4en passant square-the square a pawn has just skipped
5halfmove clock0half moves since a capture or pawn move
6fullmove number1the number of the current move
All thirty-two pieces on their starting squares, White at the bottom.
The board that the string above describes, with White to move.Open this position in the Board builderrnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Field 1: where the pieces stand

The first field lists the board rank by rank, starting with rank 8 and ending with rank 1. A slash separates one rank from the next, so a complete field has eight groups and seven slashes. Inside a group, the squares are read from the a-file to the h-file.

Letters stand for pieces: p for pawn, n for knight, b for bishop, r for rook, q for queen and k for king. Uppercase letters are white pieces and lowercase letters are black ones.

A digit from 1 to 8 counts empty squares that sit side by side. The group 8 is therefore a completely empty rank. The group 4P3 means four empty squares, a white pawn, then three empty squares, which puts that pawn on the e-file. In each group the letters and digits together cover exactly eight squares.

Fields 2 to 4: what a picture does not show

Side to move

The second field is w for White or b for Black. The same pieces with the other letter here pose a different problem, so read it before you judge a position.

Castling rights

The third field uses K and Q for White's kingside and queenside castling, and k and q for Black's, listed in that order. A hyphen means that neither side may castle any more. A letter says that the right still exists. It does not promise that castling is legal on this very turn, because pieces may stand in the way or squares may be attacked. The four letters can appear in any combination, from all of them down to a single one.

En passant square

The fourth field names the square that a pawn skipped in a two-square advance made on the last move. Otherwise it holds a hyphen. Under the PGN standard the square is recorded after every such advance, even when no enemy pawn can capture there. Some programs fill it in only when a capture is possible, so you may meet the same position written both ways.

White pawn on e4 and white king on e1; black king on e8; the skipped square e3 is marked.
White has just moved a pawn from e2 to e4. Field 4 reads e3, though Black cannot capture there.Black to move. Open this position in the Board builder4k3/8/8/8/4P3/8/8/4K3 b - e3 0 1

The full string for that diagram is 4k3/8/8/8/4P3/8/8/4K3 b - e3 0 1. Black is to move, neither side can castle, and e3, on the third rank, is the square the pawn jumped over. After a black double advance the square lies on rank 6 instead.

Fields 5 and 6: the two counters

The fifth field is the halfmove clock. A half move is one turn by one player. The clock counts half moves since the last capture or pawn move and returns to zero when either happens. It serves the fifty-move rule: at 100, each side has made fifty moves with no capture and no pawn move, and a draw can be claimed.

The sixth field is the fullmove number. It starts at 1 and grows by one after each move by Black. It tells you which move is being played, not how many half moves have gone by. After White's first move it still reads 1, and it becomes 2 once Black has replied. A capture or pawn move resets the clock but never this number.

White king on d4 and white rook on h1; black king on f7.
Move 71 of a rook ending. The clock reads 42: twenty-one turns each with no capture and no pawn move.White to move. Open this position in the Board builder8/5k2/8/8/3K4/8/8/7R w - - 42 71

The string is 8/5k2/8/8/3K4/8/8/7R w - - 42 71. The board would look the same whether the clock read 0 or 99, which is why this number has to be written down.

Reading one example from start to finish

The string to read

r3k2r/pp3ppp/2n5/3pP3/8/5N2/PP3PPP/R3K2R w Kq d6 0 14

The eight rank groups of the example
GroupRankWhat stands there
r3k2r8black rook a8, king e8, rook h8
pp3ppp7black pawns a7, b7, f7, g7, h7
2n56black knight c6
3pP35black pawn d5, white pawn e5
84nothing
5N23white knight f3
PP3PPP2white pawns a2, b2, f2, g2, h2
R3K2R1white rook a1, king e1, rook h1

Now the other five fields. The w says that White moves. Kq says that White keeps only the kingside right and Black only the queenside right. The square d6 says that Black has just advanced a pawn from d7 to d5. The clock reads 0 because that was a pawn move. The 14 says that this is move 14, with White's half still to be played.

White king on e1, rooks on a1 and h1, knight on f3 and pawn on e5; black king on e8, rooks on a8 and h8, knight on c6 and pawn on d5; each side has five more pawns.
The example on a board. White may play exd6 or castle kingside, but not queenside.White to move. Open this position in the Board builderr3k2r/pp3ppp/2n5/3pP3/8/5N2/PP3PPP/R3K2R w Kq d6 0 14

Look at White's queenside. The squares b1, c1 and d1 are empty, yet White may not castle there, since the string has no Q. The king cannot have moved, or the K would be gone too. In a real game this can happen when the a1 rook left its square earlier and later came back. A drawing alone could not have told you.

Common mistakes when reading a FEN

  • Reading rank 1 first. The string begins with rank 8, the far side from White.
  • Treating a digit as a square number. It counts empty squares.
  • Swapping the colors. Uppercase means White.
  • Taking a castling letter as a legal move. It records a right that remains.
  • Taking the fourth field as proof of a capture. It may only record the double advance.
  • Reading the last number as a count of half moves. It counts full moves.

A safe reading order

  • Count eight rank groups.
  • Place rank 8 first, starting at the a-file.
  • Read the side to move.
  • Note the castling letters and the en passant square.
  • Finish with the two counters.

To watch a string turn into a board, paste it into the Board builder, which imports FEN and can flip the view. When you are ready to produce your own, follow writing a FEN by hand.

Related guides cover why a FEN is rejected, how a position code differs from a game record and how to copy a printed diagram.

Common questions

What does FEN stand for in chess?

Forsyth-Edwards Notation, a one-line description of a chess position.

What do the letters KQkq mean?

White keeps the right to castle on both sides, and so does Black. The uppercase letters are White's.

Does a FEN store the moves of a game?

No. It stores one position and a few facts about it. The moves belong in a game record such as PGN.

What does a hyphen mean in a FEN?

In the third field, no castling rights remain. In the fourth, there is no en passant square, although some programs also write a hyphen when no capture is possible.

Sources

Keep studying

All guides on reading and writing positions