dojotrades.com

Should you save a position as FEN or a game as PGN?

Two plain text formats cover most of what a chess student wants to keep. FEN holds one position. PGN holds a game, with labels, the moves in order and the result.

You will see what goes into each, how a PGN record can begin from a FEN, what each format leaves out and how to decide which one to save.

A snapshot and a record

A FEN is a single line that describes the board at one instant, including the side to move and a few related facts. Think of it as a photograph. It says nothing about the moves that led there. The parts of the line are explained in what FEN is.

PGN stands for Portable Game Notation. A game in this format has two parts. First come tag pairs in square brackets, which label the game. Then comes the movetext, which lists the moves with their numbers and ends with the result.

The difference matters when you come back later. A snapshot lets you set up one board at once and start thinking. A record lets you walk through the moves and see how that board arose, but you have to play forward to reach it.

FEN and PGN side by side
QuestionFENPGN
What does it hold?one positiona game or a line of play
How long is it?one linetags plus movetext
Move historynoyes
Comments and side linesnoyes
Names and datenoyes, in tags
Starting from a set positionit is the positionyes, with two extra tags
White rooks on a2 and b1 and white king on g1; black king on e8.
A snapshot with White to move. Its FEN is 4k3/8/8/8/8/8/R7/1R4K1 w - - 0 1.Open this position in the Board builder4k3/8/8/8/8/8/R7/1R4K1 w - - 0 1

How PGN lays out a game

Seven tags make up the standard set, and they are listed in a fixed order before any others.

The seven standard PGN tags
TagWhat it holds
Eventthe name of the occasion
Sitewhere the game was played
Dateyear, month and day
Roundthe round number
Whitewho had the white pieces
Blackwho had the black pieces
Result1-0, 0-1, 1/2-1/2 or *

For a casual game you may not know all of these. In most tags an unknown entry is a question mark, an unknown date is written ????.??.?? and an unfinished or unknown result is an asterisk.

The movetext follows the tags, with a blank line in between. Its signs are those of algebraic notation. One file can hold many games one after another, which suits a collection of complete records.

Your own thoughts can travel with the moves. A comment is written between curly braces, and an alternative line is written inside round brackets after the move it replaces.

Starting from a position: the SetUp and FEN tags

A PGN game normally begins from the usual starting position. To begin somewhere else, such as an endgame exercise, you add two tags. SetUp holds the figure 1, and FEN holds the position. A program that reads the file places that board before it plays the first move.

A short line from the board above

These lines show the two extra tags and the movetext. The seven standard tags would come before them.

  1. [SetUp "1"]
  2. [FEN "4k3/8/8/8/8/8/R7/1R4K1 w - - 0 1"]
  3. 1. Ra7 Kd8 2. Rb8# 1-0
Checkmate: white rooks on b8 and a7 and white king on g1; black king on d8.
After 2. Rb8# it is mate. To keep this board on its own, save its own FEN.Black to move. Open this position in the Board builder1R1k4/R7/8/8/8/8/8/6K1 b - - 3 2

The FEN tag is not a summary of the game. It marks only where the movetext starts. Every later position, including the mate shown here, comes from playing the moves in turn.

Numbering follows the starting FEN. Its last field gives the number of the first move in the movetext, so a line that begins late in a game can keep its original numbers. If that position has Black to move, the movetext opens with the number followed by three dots, and then Black's move.

What each format cannot store

A FEN cannot say how a position came about. It holds no moves, no names, no result and no comment. It also cannot say whether the same position has appeared earlier, which matters for the rule that allows a draw claim when a position occurs for the third time.

White king on e1 and white knight on g1; black king on e8 and black knight on g8.
Play Nf3, Nf6, Ng1 and Ng8 and the pieces return to these squares.White to move. Open this position in the Board builder4k1n1/8/8/8/8/8/8/4K1N1 w - - 0 1

After those four half moves the board looks exactly as before. The line was 4k1n1/8/8/8/8/8/8/4K1N1 w - - 0 1 at first and is 4k1n1/8/8/8/8/8/8/4K1N1 w - - 4 3 afterward. Only the counters changed. Neither line says that this is a second visit. With the moves written in a game record, a reader can replay them and count.

For a position to count as the same one, the same side must be to move and the castling and en passant possibilities must match, not only the pieces. A reader with the full movetext can check all of that.

PGN has limits too. It records what was played, and it explains a move only if someone typed a comment. When a game begins from a set position, whatever happened before that board is absent from the record.

Which to save, and when to keep both

Choosing a format by purpose
You want toSave
keep one exercise or ideaFEN
replay how a game wentPGN
keep a line with alternative movesPGN
put a single puzzle on a sheetFEN
study one moment of a recorded gameboth

Keeping both is often the neat answer. Save the whole game as PGN, then copy the FEN of the one or two moments you want to think about. Beside each FEN, note the game and the move number so that you can find your way back.

A useful habit is to write one sentence with each FEN that says what you want to find there. The line itself cannot carry that question, and a bare board is easy to forget.

Single positions fit well in a study notebook. With the Board builder you can paste or copy a FEN and save the position with a title, a note and tags. That notebook is stored only in the browser you use, so keep a plain text copy of the FEN lines you care about.

Common mistakes when choosing a format

  • Saving only the final FEN of a game and expecting to replay it later.
  • Pasting a whole game where a position is expected. A position box wants one FEN line.
  • Adding a FEN tag without SetUp. The standard asks for the two together.
  • Changing the starting FEN but not the moves, which can make the first move illegal.
  • Reading repetition from a FEN. The line carries no list of earlier positions.

Before you file it

  • Decide whether you need the whole story or only one moment.
  • In a PGN, check that the Result tag matches the end of the movetext.
  • In a FEN, check the side to move.
  • For a game from a set position, check both extra tags.
  • Write down where the position came from.

To produce a position line yourself, without any software, follow writing a FEN by hand. It takes the board one rank at a time.

Common questions

Can a FEN be turned into a PGN?

You can place it in the FEN tag of a game that starts from that board, together with SetUp. Earlier moves cannot be recovered, because a FEN does not contain them.

Does every PGN file contain a FEN?

No. A game from the usual starting position does not need one. A game that starts from a set position carries it in a tag.

Which format keeps castling rights?

Both. A FEN states them directly, and in a PGN they follow from the starting board and the moves.

Can I read PGN without special software?

Yes. It is plain text, so you can open it in a text editor and play the moves on a real board.

Sources

Keep studying

All guides on reading and writing positions