Filename extension | .pgn |
---|---|
Internet media type | application/vnd.chess-pgn |
Developed by | Steven J. Edwards |
Initial release | 1993 |
Type of format | Chess game record |
Portable Game Notation (PGN) is a plain text computer-processible format for recording chess games (both the moves and related data), supported by many chess programs.
PGN was devised around 1993, by Steven J. Edwards, and was first popularized via the Usenet newsgroup rec.games.chess.
PGN is structured "for easy reading and writing by human users and for easy parsing and generation by computer programs." The chess moves themselves are given in algebraic chess notation. The usual filename extension is .pgn
.
There are two formats in the PGN specification, the "import" format and the "export" format. The import format describes data that may have been prepared by hand, and is intentionally lax; a program that can read PGN data should be able to handle the somewhat lax import format. The export format is rather strict and describes data prepared under program control, similar to a pretty printed source program reformatted by a compiler. The export format representations generated by different programs on the same computer should be exactly equivalent, byte for byte.
PGN code begins with a set of "tag pairs" (a tag name and its value), followed by the "movetext" (chess moves with optional commentary).
Tag pairs begin with an initial left bracket [
, followed by the name of the tag in plain text (ASCII). The tag value is enclosed in double-quotes, and the tag is then terminated with a closing right bracket ]
. A quote inside a tag value is represented by the backslash immediately followed by a quote. A backslash inside a tag value is represented by two adjacent backslashes. There are no special control codes involving escape characters, or carriage returns and linefeeds to separate the fields, and superfluous embedded spaces (or SPC characters) are usually skipped when parsing.