FEN Strings: How Chess Positions Fit in One Line
FEN (Forsyth-Edwards Notation) describes any chess position as a single line of text. Here's how it works, field by field, with ASCII boards and worked examples.
A FEN string packs an entire chess position into one line of text. No move history, no screenshot, just the board, whose turn it is, and a few rules flags.
What Is FEN?
FEN stands for Forsyth-Edwards Notation. It’s the standard way to write one chess position as plain text.
FEN is not PGN (Portable Game Notation). PGN records a whole game. FEN records one frozen frame.
The Six Fields
A FEN string has six fields separated by spaces. Here’s the starting position:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
The six fields, in order:
- Piece placement: where every piece sits
- Active color: whose turn it is
- Castling rights: who can still castle, and to which side
- En passant target: where an en passant capture could land
- Halfmove clock: counter for the fifty-move rule
- Fullmove number: which move of the game we’re on
Let’s break each one down.
Field 1: Piece Placement
Ranks are read from 8 down to 1, separated by /. Within each rank, files run a to h.
| Letter | Piece |
|---|---|
p | pawn |
r | rook |
n | knight |
b | bishop |
q | queen |
k | king |
Lowercase = black. Uppercase = white. Digits = empty squares in a row. 8 is a fully empty rank. 3p4 means three empty, a black pawn, four empty.
The starting position as a board:
┌─────────────────┐
8 │ r n b q k b n r │
7 │ p p p p p p p p │
6 │ . . . . . . . . │
5 │ . . . . . . . . │
4 │ . . . . . . . . │
3 │ . . . . . . . . │
2 │ P P P P P P P P │
1 │ R N B Q K B N R │
└─────────────────┘
a b c d e f g h
Mapped rank by rank:
rank 8 rnbqkbnr → r n b q k b n r
rank 7 pppppppp → p p p p p p p p
rank 6 8 → . . . . . . . .
rank 5 8 → . . . . . . . .
rank 4 8 → . . . . . . . .
rank 3 8 → . . . . . . . .
rank 2 PPPPPPPP → P P P P P P P P
rank 1 RNBQKBNR → R N B Q K B N R
Field 2: Active Color
One letter. w for white to move, b for black.
Field 3: Castling Rights
Each letter marks one castling right still available:
K: white kingsideQ: white queensidek: black kingsideq: black queenside
Drop letters when the king or matching rook moves. - means neither side can castle at all.
This tracks whether castling has been permanently lost. It doesn’t check whether castling is legal right now.
Field 4: En Passant Target
Whenever a pawn advances two squares, the square it skipped over becomes the en passant target. After 1. e4, that square is e3.
The quirk: this field is set whenever a pawn moves two squares, even if there’s no enemy pawn nearby to capture. If no pawn moved two squares last turn, the field is -.
Field 5: Halfmove Clock
A halfmove (or ply) is one move by one player. The clock counts plies since the last capture or pawn push. Any capture or pawn move resets it to 0. When it hits 100, the game is drawn by the fifty-move rule.
Field 6: Fullmove Number
Starts at 1. Increments every time black completes a move.
A Worked Example
Let’s walk through the first two moves of a Sicilian Defense.
Starting position:
┌─────────────────┐
8 │ r n b q k b n r │
7 │ p p p p p p p p │
6 │ . . . . . . . . │
5 │ . . . . . . . . │
4 │ . . . . . . . . │
3 │ . . . . . . . . │
2 │ P P P P P P P P │
1 │ R N B Q K B N R │
└─────────────────┘
a b c d e f g h
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
After 1. e4:
┌─────────────────┐
8 │ r n b q k b n r │
7 │ p p p p p p p p │
6 │ . . . . . . . . │
5 │ . . . . . . . . │
4 │ . . . . P . . . │
3 │ . . . . * . . . │
2 │ P P P P . P P P │
1 │ R N B Q K B N R │
└─────────────────┘
a b c d e f g h
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
Changes:
- Rank 4:
8→4P3 - Rank 2:
PPPPPPPP→PPPP1PPP - Active color:
w→b - En passant:
-→e3
After 1... c5:
┌─────────────────┐
8 │ r n b q k b n r │
7 │ p p . p p p p p │
6 │ . . * . . . . . │
5 │ . . p . . . . . │
4 │ . . . . P . . . │
3 │ . . . . . . . . │
2 │ P P P P . P P P │
1 │ R N B Q K B N R │
└─────────────────┘
a b c d e f g h
rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2
Changes:
- Rank 7:
pppppppp→pp1ppppp - Rank 5:
8→2p5 - Active color:
b→w - En passant:
e3→c6(square the black pawn skipped) - Fullmove:
1→2(black just completed a move)
FEN vs PGN
- PGN records a full game. Use it to replay moves or share a complete game.
- FEN records one position. Use it for puzzles, engine analysis, or sharing a specific moment.
You can also start a PGN from any FEN, which is handy for studying middlegames or endgames.
Where You’ll See FEN
- Chess.com and Lichess export and load FEN from analysis boards.
- Stockfish takes FEN as input for position evaluation.
- Puzzle databases store positions as FEN because it’s compact and unambiguous.
- Chess libraries like
python-chessandchess.jsuse FEN as their standard board format.
If you’re building anything chess-related, FEN is table stakes.
Wrapping Up
FEN is one of those small, well-designed standards that quietly holds an ecosystem together. Six fields, a few rules, and any chess position fits on one line.
Glossary
- FEN: Forsyth-Edwards Notation. A single-line text format for one chess position.
- PGN: Portable Game Notation. A text format for recording an entire chess game, move by move.
- Ply / Halfmove: One move by one player. Two plies make a full move.
- En passant: A special pawn capture where a pawn that has just moved two squares can be captured as if it had only moved one.
- Fifty-move rule: A draw rule triggered when fifty moves pass with no capture and no pawn move.
- Rank: A horizontal row of the chessboard, numbered 1 to 8.
- File: A vertical column of the chessboard, lettered a to h.
- Stockfish: A popular open-source chess engine.
- UCI: Universal Chess Interface. The protocol most chess engines use to talk to GUIs.
Game Programmer & Co-Founder of PixelPunch LLP. I ship games, build tools, and make the web work harder.
Know more →