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.
Valid FEN.
White at the bottom. Red frames mark squares with a problem.
- 1
Piece placement
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNRWhite 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
Side to move
wWhite to move.
- 3
Castling rights
KQkqWhite 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
En passant square
-No pawn just moved two squares, so there's no en passant capture this move.
- 5
Halfmove clock
00: the last move was a pawn move or a capture (or the count starts here).
- 6
Move number
1Move 1, the start of the game or of a set-up position. It goes up by one after each Black move.
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
| # | Field | Here | What it says |
|---|---|---|---|
| 1 | Piece placement | rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR | Where every piece stands, rank by rank from the 8th. |
| 2 | Side to move | w | White to move. |
| 3 | Castling rights | KQkq | Both sides can still castle on both wings. |
| 4 | En passant square | - | No pawn just moved two squares. |
| 5 | Halfmove clock | 0 | Moves since the last capture or pawn move. |
| 6 | Move number | 1 | The 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:
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1The 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:
KWhite can castle kingside (O-O),Qqueenside (O-O-O).kandqare 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:
r1bqk2r/pppp1ppp/2n2n2/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 6 5White 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:
rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3The 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
| Rank | Written | Reads as |
|---|---|---|
| 8 | r1bqkb1r | rook, empty, bishop, queen, king, bishop, empty, rook |
| 7 | pppp1Qpp | four black pawns, empty, the white queen on f7, two pawns |
| 6 | 2n2n2 | two empty, knight on c6, two empty, knight on f6, two empty |
| 5 | 4p3 | four empty, a black pawn on e5, three empty |
| 4 | 2B1P3 | two empty, the white bishop on c4, empty, a pawn on e4 |
| 3 | 8 | an empty rank |
| 2 | PPPP1PPP | White's pawns, with e2 empty |
| 1 | RNB1K1NR | d1 and f1 empty: the queen and bishop have left |
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, not44. - The wrong case.
kis Black's king. A FEN with twoKs and nokhas two white kings. - A pawn on the 1st or 8th rank. It would already have promoted.
- Castling rights that the pieces don't allow.
Kneeds 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'sKQkq.
bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w HFhf - 0 1The 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.