Notation & vision

FEN: Chess Position Notation

FEN (Forsyth-Edwards Notation) writes a whole chess position on one line: where the pieces stand, who moves, castling, en passant and two move counters. Paste one below to see the board and what each part says, or read on to write your own.

Try it

Check a FEN

Paste or type a FEN. The board follows as you type, each field is explained, and anything wrong is listed with a fix. When a fix is safe to make, you get a corrected FEN.

Try:

Valid FEN.

White at the bottom. Red frames mark squares with a problem.

  1. 1

    Piece placementrnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

    White has king, 1 queen, 2 rooks, 2 bishops, 2 knights and 8 pawns (16 pieces). Black has king, 1 queen, 2 rooks, 2 bishops, 2 knights and 8 pawns (16 pieces).

  2. 2

    Side to movew

    White to move.

  3. 3

    Castling rightsKQkq

    White can castle on both sides; Black can castle on both sides. A right means the king and rook haven't moved yet; whether castling is legal right now depends on the position.

  4. 4

    En passant square-

    No pawn just moved two squares, so there's no en passant capture this move.

  5. 5

    Halfmove clock0

    0: the last move was a pawn move or a capture (or the count starts here).

  6. 6

    Move number1

    Move 1, the start of the game or of a set-up position. It goes up by one after each Black move.

Analyze Open in board editor

Free, in your browser: nothing you paste is uploaded.

The six fields

A FEN is six fields separated by single spaces. Here is the starting position:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

#FieldHereWhat it says
1Piece placementrnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNRWhere every piece stands, rank by rank from the 8th.
2Side to movewWhite to move.
3Castling rightsKQkqBoth sides can still castle on both wings.
4En passant square-No pawn just moved two squares.
5Halfmove clock0Moves since the last capture or pawn move.
6Move number1The game is on move 1.

The first field is the long one and the one people mean when they say “the FEN”. The other five are short, and each has exactly one job.

1. Piece placement, rank by rank

The board is written one rank (row) at a time:

  • From the top. The first rank written is the 8th, Black's side. The last is the 1st, White's side. Slashes separate the ranks, so there are always seven.
  • Left to right. Each rank runs from the a-file to the h-file, as White sees it.
  • Letters are pieces. K king, Q queen, R rook, B bishop, N knight, P pawn. Capitals are White, small letters Black.
  • Digits are empty squares. 3 means three empty squares in a row; 8 is an empty rank. Every rank adds up to 8.

After 1. e4 the white pawn leaves e2 and lands on e4. Rank 4 becomes 4P3 (four empty squares, the pawn, three empty) and rank 2 becomes PPPP1PPP:

The position after 1. e4, the pawn's start and end squares highlighted
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

The letters come from English: N is the knight because K is taken by the king. A FEN written with another language's letters, like S for the German Springer, won't load.

2. Side to move

w if White moves next, b if Black does. It's a single small letter, and it matters more than it looks: the same position can be won with White to move and lost with Black to move. After 1. e4 it's b.

3. Castling rights

Which castling moves are still allowed later in the game, not whether castling is possible right now:

  • K White can castle kingside (O-O), Q queenside (O-O-O).
  • k and q are the same for Black.
  • - when neither side can castle.

A right is lost for good once the king moves, or once that rook moves. Pieces in the way or a check only stop castling for now, so they don't change the FEN. Write the letters in the order KQkq. Here White has castled and Black still can on both sides:

An Italian Game position after White has castled; Black's king and rooks are highlighted on their starting squares
r1bqk2r/pppp1ppp/2n2n2/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 6 5
White has castled, so only kq is left.

See how castling works for the full rule.

4. En passant square

When a pawn has just moved two squares, this field names the square it skipped: the square an enemy pawn would land on to take it en passant. Otherwise it's -.

After 1. e4 d5 2. e5 f5, Black's f-pawn has just skipped f6, and the white pawn on e5 can take it by moving to f6:

White pawn on e5 next to a black pawn that just moved to f5; f6, the en passant square, highlighted
rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3

The square is always on the 3rd rank (a white pawn just moved, Black to move) or the 6th (a black pawn just moved, White to move). The original standard writes it after every two-square pawn move; many programs write it only when a capture is really possible. That's why you'll see the FEN after 1. e4 with e3 on some sites and - on others. Both are correct.

5 and 6. The move counters

The halfmove clock counts single moves, by either player, since the last capture or pawn move. Any capture or pawn move resets it to 0. It exists for the fifty-move rule: at 100 (fifty moves each) either player can claim a draw, and at 150 the game is drawn automatically.

The move number starts at 1 and goes up after each Black move, the same number you see in front of the moves in a game score. In the Italian position above, 6 5 means six single moves without a pawn move or capture, and White is about to play move 5.

Read a FEN, rank by rank

Here is the end of the Scholar's Mate, 1. e4 e5 2. Bc4 Nc6 3. Qh5 Nf6 4. Qxf7#:

r1bqkb1r/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4

RankWrittenReads as
8r1bqkb1rrook, empty, bishop, queen, king, bishop, empty, rook
7pppp1Qppfour black pawns, empty, the white queen on f7, two pawns
62n2n2two empty, knight on c6, two empty, knight on f6, two empty
54p3four empty, a black pawn on e5, three empty
42B1P3two empty, the white bishop on c4, empty, a pawn on e4
38an empty rank
2PPPP1PPPWhite's pawns, with e2 empty
1RNB1K1NRd1 and f1 empty: the queen and bishop have left
Scholar's Mate: the white queen on f7, supported by the bishop on c4, mates the black king on e8
The queen on f7 gives mate.

Then the short fields: b Black to move (but there's no move: it's mate), KQkq nobody has castled or moved a king or rook, - no en passant, 0 because the last move was a capture, and 4 for move four.

Common mistakes

The FEN box above catches all of these:

  • A rank that doesn't add up to 8. Count letters plus digits on each rank. One missed empty square shifts every piece after it.
  • Starting from the wrong side. The first rank in a FEN is the 8th. Writing White's pieces first turns the board upside down and puts the pawns on the wrong ranks.
  • Two digits in a row. Write 8, not 44.
  • The wrong case. k is Black's king. A FEN with two Ks and no k has two white kings.
  • A pawn on the 1st or 8th rank. It would already have promoted.
  • Castling rights that the pieces don't allow. K needs the white king on e1 and a rook on h1, and the same for the others.
  • An impossible en passant square, on the wrong rank for the side to move or with no pawn that just moved past it.
  • The side not to move is in check. If Black is in check, it must be Black's move. This usually means the side to move is wrong.
  • Missing fields. A bare placement loads in some programs and not in others. Add w - - 0 1 (with the right side and castling) to be safe.

Chess960: Shredder-FEN and X-FEN

In Chess960 the back rank is shuffled, so “kingside rook on h1” no longer holds. Two versions of FEN deal with that in the castling field. The rest of the FEN is the same.

  • Shredder-FEN writes the file of each castling rook: capitals for White, small letters for Black. The usual rooks are HAha.
  • X-FEN keeps KQkq, meaning the outermost rook on that side of the king, and switches to a file letter only when the castling rook is an inner one (two rooks on the same side). For this position it's KQkq.
A Chess960 starting position with the king on g1 between rooks on f1 and h1
bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w HFhf - 0 1
The kings stand on g1 and g8, between rooks on the f- and h-files, so Shredder-FEN writes HFhf.

EPD

EPD (Extended Position Description) is FEN's cousin for test positions. It keeps the first four fields and replaces the two counters with operations ending in semicolons, like bm Nf3; for the best move or id "name"; for a label. Engine test suites are stored this way. Paste an EPD line into the box above and it is turned into a plain FEN.

Where to use a FEN

  • Set up a position in the board editor by placing pieces, and it writes the FEN for you. It works the other way too: paste a FEN and fix it by hand.
  • Paste a FEN into the analysis board to see the best moves for that position.
  • Moves are written in chess notation, and whole games in PGN: open one in the PGN viewer.

Frequently asked questions

What does FEN stand for?

Forsyth-Edwards Notation. It is named after David Forsyth, a Scottish chess journalist who used this way of writing positions in the 19th century, and Steven J. Edwards, who extended it for computers as part of the PGN standard in 1994.

What is the FEN of the starting position?

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1. Black's pieces on rank 8, Black's pawns, four empty ranks, White's pawns, White's pieces; White to move, all four castling rights, no en passant square, halfmove clock 0, move 1.

What is the difference between FEN and PGN?

A FEN describes one position. A PGN records a whole game: the moves, the players, the result. A PGN can start from a FEN when the game didn't begin from the usual starting position, and every position in a PGN game can be written as a FEN.

Why do capital and small letters matter in a FEN?

Capitals are White's pieces and small letters are Black's. K is the white king and k the black king, so changing the case of a letter swaps a piece to the other side.

How do I get the FEN of a position?

Most chess sites show it under the analysis board or in a share menu. To make one yourself, set up the position in our board editor and it writes the FEN for you as you place the pieces.

Can a FEN show a threefold repetition?

No. A FEN holds one position and nothing about the moves that led to it, so it can't tell whether the position has appeared before. For repetition you need the game's moves, which is what PGN stores.

Why does my FEN say e3 when no pawn can capture?

The original standard writes the en passant square after every two-square pawn move, whether or not a capture is possible. Many programs write it only when an en passant capture is really possible, so the same position can have two FENs that differ only there. Both are valid.

Does FEN work for Chess960?

Yes, with a change to the castling field. Shredder-FEN writes the files of the castling rooks (HAha for the usual rook squares), and X-FEN keeps KQkq and adds a file letter only when it would be unclear which rook castles.

Keep practicing