Forsyth-Edwards Notation

Home * Chess * Position * Forsyth-Edwards Notation

Forsyth-Edwards Notation (FEN) describes a Chess Position. It is an one-line ASCII-string. FEN is based on a system created by Scotsman David Forsyth in the 19th century. Steven Edwards specified the FEN standard for computer chess applications as part of the Portable Game Notation.

=FEN Syntax= One FEN string or record consists of six fields separated by a space character. The first four fields of the FEN specification are the same as the first four fields of the EPD specification.

''Terminal and nonterminal symbols of a variant of BNF below are embedded in ' ' resp. < >.''  ::=  ' '  ' '  ' '  ' '  ' ' 

Piece Placement
The Piece Placement is determined rank by rank in big-endian order, that is starting at the 8th rank down to the first rank. Each rank is separated by the terminal symbol '/' (slash). One rank, scans piece placement in little-endian file-order from the A to H.

A decimal digit counts consecutive empty squares, the pieces are identified by a single letter from standard English names for chess pieces as used in the Algebraic Chess Notation. Uppercase letters are for white pieces, lowercase letters for black pieces.  ::= '/' '/' '/' '/' '/' '/' '/' ::= [ ] {[ ] } [ ] | '8'      ::=  |  ::= '1' | '2' | '3' | '4' | '5' | '6' | '7'  ::= 'P' | 'N' | 'B' | 'R' | 'Q' | 'K'  ::= 'p' | 'n' | 'b' | 'r' | 'q' | 'k'

Side to move
Side to move is one lowercase letter for either White ('w') or Black ('b').  ::= {'w' | 'b'}

Castling ability
If neither side can castle, the symbol '-' is used, otherwise each of four individual castling rights for king and queen castling for both sides are indicated by a sequence of one to four letters.  ::= '-' | ['K'] ['Q'] ['k'] ['q'] (1..4)

En passant target square
The en passant target square is specified after a double push of a pawn, no matter whether an en passant capture is really possible or not. Other moves than double pawn pushes imply the symbol '-' for this FEN field.  ::= '-' | ::=  <fileLetter> ::= 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h'    ::= '3' | '6'

Halfmove Clock
The halfmove clock specifies a decimal number of half moves with respect to the 50 move draw rule. It is reset to zero after a capture or a pawn move and incremented otherwise. <Halfmove Clock> ::= { } ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Fullmove counter
The number of the full moves in a game. It starts at 1, and is incremented after each Black's move. <Fullmove counter> ::= { } ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'  ::= '0' |

=Samples= FEN strings of Starting Position and after 1.e4 c5 2.Nf3: <fentt border="none" style="font-size:16pt">rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 <fentt border="none" style="font-size:16pt">rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR 1.e4 rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1 <fentt border="none" style="font-size:16pt">rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR 1.e4 c5 rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2 <fentt border="none" style="font-size:16pt">rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R 1.e4 c5 2.Nf3 rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2

=See also=
 * Extended Position Description (EPD)
 * Forsyth-Edwards Expanded Notation (FEEN)
 * Portable Game Notation (PGN)

=Forum Posts=

2000 ...

 * File name extensions by Leen Ammeraal, CCC, November 14, 2000
 * Making positions in eps by Renze Steenhuisen, CCC, October 27, 2003 » Fen2eps

2005 ...

 * contradicting FEN and SMK-FEN by Reinhard Scharnagl, CCC, August 04, 2005
 * fen to fen functions by Uri Blass, CCC, May 21, 2007

2010 ...

 * where FEN is not consistent by Reinhard Scharnagl, CCC, January 06, 2010
 * FEN string by colin, CCC, January 30, 2011
 * No more pseudolegal en passant target foolishness by Steven Edwards, CCC, February 27, 2011
 * What's wrong with this EPD? by Jouni Uski, CCC, March 20, 2011
 * Question about Shredder FEN and X-FEN by Harm Geert Muller, CCC, April 22, 2012
 * Re: Causes for inconsistent benchmark signatures by Evert Glebbeek, CCC, March 27, 2013 » En passant
 * The maximum character length of a FEN string by Steven Edwards, CCC, August 24, 2013
 * Is 79 maximal? by Louis Zulli, CCC, July 29, 2014
 * PGN to FEN (with Evaluation)? by Steve Maughan, CCC, December 28, 2014 » Portable Game Notation, Python

2015 ...

 * Binary FEN by J. Wesley Cleveland, CCC, July 24, 2015
 * Any tool to convert FEN strings to diagrams? by Ted Wong, CCC, February 15, 2016
 * FEN - Flipper for Windows by Matthias Gemuh, CCC, May 17, 2017 » Color Flipping, EPD
 * 50 move counter in FEN and GUIs by Jouni Uski, CCC, November 12, 2019

=External Links=
 * Forsyth-Edwards Notation from Wikipedia
 * Chess Programming - Chess Board Implementation : A FEN parser by Thomas Petzke
 * FEN Database by Mathieu Pagé
 * Gilith - Chess Diagram Maker by Joe Leslie-Hurd
 * fen2img Chess Diagram Maker by Joe Leslie-Hurd


 * Chess Diagram Generator
 * Chessforeva: 3D chess diagram from FEN » 3D Graphics Board
 * Fen2eps by Dirk Baechle

=References=

Up one Level