The Forsyth-Edwards Notation in Chess (FEN).

Sri Vathsan
4 min readJul 8, 2021

Introduction

Forsyth-Edwards Notation or FEN for short is a standard notation in Chess that is used to denote a particular game state in the game. It is used all over the world for sharing positions across multiple sites / players. Think of it as JSON for chess.

It was devised by the Scot Journalist David Forsyth and was extended by Steven Edwards to be able to read and understood by computers.

An Example FEN looks like this :

rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq — 1 2

This is taken from the opening three moves of the popular Chess Opening Sicilian Defence. (ECO B20-B99) (For the uninitiated, it means the openings 20–99 in Volume B of the Encyclopaedia of Chess Openings.)

Though at the outset, it may look like gibberish hash of string but it follows a certain rule in its construction. Let us divide the entire FEN string into 5 parts, each separated by the 5 spaces.

1. Piece Placement

rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R

This initial substring defines the position of various pieces on the chess board. Each row of the chess board is separated by “/” starting from the 8th rank down to the 1st.

Uppercase letters denote the White Pieces with the standard chess notation (R-Rook, N-Knight, B-Bishop, Q-Queen, K-King, P-Pawn), while the Black pieces are denoted by lowercase letters.

So, according to the FEN in hand, the 8th rank is filled with black pieces in the initial order.

The 7th Rank is filled with pawns except at the third position (the c7 square) which is denoted by the number 1 ( 1 vacant square after 2 pawns).

The 6th Rank is completely vacant so it is just denoted by 8 ; meaning 8 vacant squares.

The 5th Rank contains 2 vacant squares, a black pawn and 5 vacant squares.

And So on and so forth.

2. Active Colour

This position has only 2 possible values “w” or “b” denoting who moves next. Here black has to move next.

3. Castling Privilege

KQkq

Denoted the castling privileges of both sides where

K - White can castle King Side
Q - White can castle Queen Side
k - Black can castle King Side
q - Black can castle Queen Side

So in this position, both sides has both castling privileges! If neither side can castle, it is denoted by a “-”.

4. En Passant Target

En Passant target is the square in which the square 1 behind a pawn which has recently moved 2 steps ahead. For example:

Black can en-passant to d3 so it is denoted as d3. But, if black plays some other move, say b6,

Black can no longer en passant, so it is denoted by a “-”, as it is in the case given above.

5. Halfmove Clock

The number of half moves that was made since the last pawn move or the last capture of a piece. (As reference to the Fifty Move Rule).

The fifty-move rule in chess states that a player can claim a draw if no capture has been made and no pawn has been moved in the last fifty moves (for this purpose a “move” consists of a player completing a turn followed by the opponent completing a turn). The purpose of this rule is to prevent a player with no chance of winning from obstinately continuing to play indefinitely or seeking to win by tiring the opponent. (From Wikipedia, the free encyclopedia)

Here it is 1 moves since the last pawn move, c5.

6. Fullmove number

It is the number of moves or “full moves” that has occured in the game. A move is incremented by 1 whenever black plays a move. However, it starts with 1 .

Many applications exist to verify if a FEN is in correct format but the most simplest and most elegant one is using a regex .

^((([pnbrqkPNBRQK1-8]{1,8})\/?){8})\s+(b|w)\s+(-|K?Q?k?q)\s+(-|[a-h][3-6])\s+(\d+)\s+(\d+)\s*

Hope you understood this explanation of FEN and have a great day!

All screenshots were taken from Lichess.

--

--