This is the home page for the pgn-extract program, which is a command-line program for manipulating chess games recorded in the Portable Game Notation (PGN).

A full description of pgn-extract's functionality is available and included with the sources.

Here you can find the C source code and win32 binary for the current version. pgn-extract compiles and runs under Windows, Linux and Mac OSX. This program is made available under the terms of the GNU General Public License (Version 1).


The program is designed to make it easy to extract selected games from a PGN format data file based on a wide variety of criteria. The criteria include:

  • textual move sequences;

  • the position reached after a sequence of moves;

  • information in the tag fields;

  • fuzzy board position;

  • and material balance in the ending.

The program includes a semantic analyser which will report errors in game scores and it is also able to detect duplicate games found in its input files.

The range of input move formats accepted is fairly wide and includes recognition of lower-case piece letters for English and upper-case piece letters for Dutch and German. The output is normally in English Standard Algebraic Notation (SAN), but this can be varied.

Extracted games may be written out either including or excluding comments, NAGs, variations, move numbers, tags and/or results. Games may be given ECO classifications derived from the accompanying file eco.pgn, or a customised version provided by the user.

The program is designed to be relatively memory-friendly, so it does not retain a game's moves in memory once it has been processed.

Use the --help argument to the program to get the full lists of arguments.

New in version 17-1x

These are the major additions in version 17-1x:

  • Null moves (--) in variations now recognised. This is non-standard PGN notation. Note that there is scope for semantic errors here, so please let me know if you come across any game scores containing null moves that pgn-extract does not deal with correctly.

  • v17-14 corrected a long-standing error in the whole-move number in FEN output.

  • --fuzzydepth flag allows duplicate detection based on position reached at a particular ply depth.

  • -Wuci outputs a game in a format suitable for input to a UCI-compatible engine.

  • Board position matches with the -t flag that allow fuzzy board position matches.

  • A test suite of the program's basic functionality to support regression testing. This won't be of interest to users but might be to developers.

Available Files

You can take a copy of the full source and documentation as either pgn-extract-17-14.tgz or Alternatively, a win32 binary is available.

Name Description Size Date
GZipped tar file of the complete source of version 17-14 of the program.
Includes help.html, Makefile for compilation and eco.pgn file for ECO classification.
291524 bytesJun 19 2013 Zipped file of the complete source of version 17-14 of the program.
Includes help.html, Makefile for compilation and eco.pgn file for ECO classification.
403727 bytesJun 19 2013
pgn-extract-17-14.exe win32 binary of version 17-14 of the program. 482419 bytesJun 29 2013
pgn-extract-17-14c.exe Alternative win32 binary of version 17-14 of the program (requires cygwin). 386378 bytesJun 19 2013 Zipped version of eco.pgn. 32081 bytesMay 24 2013
eco.pgn File of openings with PGN classification.
This file is already included in the source archives.
254723 bytesMay 24 2013
COPYING GNU General Public License (version 1). 12488 bytesDec 05 1997


Feedback and suggestions for further features are always welcome, although I can't always promise to undertake significant development work.