React Chessboard UI

v
menu
hide

FEN errors

If the FEN value is invalid, the chessboard uses the default starting position and shows a FEN notation error. Check the FEN string for the common problems below.

Piece placement length

The first FEN field describes the pieces on the board ranks. The board size is detected from this field, so every rank must expand to the same number of squares. The number of ranks defines the board height.

Common problems:

// Invalid: the first rank expands to 9 squares, while the other ranks expand to 8.
"rnbqkbnr1/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

// Valid 8x8 board.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

// Valid 12x12 board.
"qqrnbqkbnrqq/pppppppppppp/12/12/12/12/12/12/12/12/PPPPPPPPPPPP/QQRNBQKBNRQQ w - - 0 1"

Incorrect pieces

Piece placement can contain only valid chess piece letters and empty-square numbers.

Valid piece letters:

// Invalid: "x" is not a FEN piece.
"rnbqkbnx/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

// Valid.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

Incorrect en passant square

The en passant target square is the fourth FEN field. It must be - when there is no en passant target, or a valid board square on rank 3 or 6.

Common problems:

// Invalid: e4 cannot be an en passant target square.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq e4 0 1"

// Valid: no en passant target.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

Incorrect castling

Castling availability is the third FEN field. It must be - or a combination of K, Q, k, and q.

Common problems:

// Invalid: "A" is not a castling marker.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQAq - 0 1"

// Valid.
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"