PGN / FEN
PGN is a file format for whole games: header lines with players, place and date, then the moves in notation, plus comments and variations. FEN describes a single position in one line, rank by rank from the eighth to the first, with capital letters for White and small letters for Black, plus who is to move.
Example: On every game page you save the whole game with “Download the game as PGN” and can open it in another chess program. The FEN of the starting position begins with rnbqkbnr/pppppppp/8: small letters for the black pieces and pawns on the eighth and seventh ranks, and the 8 stands for a completely empty rank.
PGN and FEN are two formats that chess programs use to exchange games and positions. Both are plain text: you can read them, copy them and paste them into another program.
PGN records a whole game, FEN a single position. With PGN you replay a game; with FEN you set up a position at once.
What a PGN file looks like
A PGN file begins with header lines in square brackets, such as [White "Nimzowitsch"] or [Result "1-0"]. Seven of them are always included: event, site, date, round, White, Black and result.
Then come the moves in short notation, always with English piece letters, whatever language the program uses. For example, 2. Nf3 means that White moves a knight to f3 on move two. Comments are in curly brackets, side lines in round brackets.
In the course you download any game with “Download the game as PGN”. You can also save your own analyses as PGN and load them again later.
How a FEN is built
A FEN consists of six parts, separated by spaces. The first describes the squares rank by rank, from the eighth to the first, each rank from the a-file to the h-file. A letter stands for a piece, a number for that many empty squares.
The second part says who is to move: w for White, b for Black. The third gives the castling rights (K and Q for White, k and q for Black), the fourth a possible en passant square.
The fifth part counts the half-moves since the last pawn move or capture; it helps with the fifty-move rule. The sixth is the number of the move that is now due.
The example position as a FEN
After 1.e4 e5 2.Nf3 Nc6 the FEN is r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3. It is White to move (w), both sides may still castle (KQkq), and there is no en passant square (-).
Since the last pawn move 1… e5, two half-moves without a pawn move and without a capture have been played, 2.Nf3 and 2… Nc6; that is why there is a 2. The 3 at the end means: now comes the third move.
See it on the board
Our own teaching example
The position after 1.e4 e5 2.Nf3 Nc6. Its FEN ends with w KQkq - 2 3: White to move, all castling rights, no en passant square, two half-moves since the last pawn move, third move.
White to move
White: Ke1, Qd1, Ra1, Rh1, Bc1, Bf1, Nb1, Nf3, a2, b2, c2, d2, e4, f2, g2, h2. Black: Ke8, Qd8, Ra8, Rh8, Bc8, Bf8, Nc6, Ng8, a7, b7, c7, d7, e5, f7, g7, h7.
Common mistakes
- Mixing up capital and small letters in a FEN. A capital K is the white king, a small k the black king.
- Entering a FEN without castling rights although castling is still allowed. Then the program forbids castling.
- Believing that a PGN file contains the position after every move. It contains the moves; the program works out the positions from them.
In these lessons
No lesson covers this term yet.
You can also search for:PGN · FEN · PGN file · FEN string · FEN code · Portable Game Notation · Forsyth–Edwards Notation · game file