Introduction
Chess engines, databases, and online platforms all speak the same two notation languages: FEN for describing a single board position, and PGN for recording an entire game. If you have ever pasted a FEN string into lichess or chess.com and wondered what each field actually means, or opened a PGN file and struggled to read the move list, this decoder makes both formats readable. It parses FEN into a visual board with piece placement, castling rights, and move clocks, and it extracts PGN headers and moves into a clean numbered list. Everything runs in your browser with no server round-trip.
What this tool does
- Parse FEN (Forsyth-Edwards Notation) strings into a visual 8x8 board with Unicode chess pieces, active color, castling rights, en passant target square, halfmove clock, and fullmove number
- Validate FEN structure: checks for exactly 8 ranks separated by slashes, each rank summing to 8 squares, valid piece characters (KQRBNPkqrbnp), and active color of w or b
- Parse PGN (Portable Game Notation) text by extracting tag pairs from bracketed headers like [Event "..."] and [White "..."] into a structured key-value list
- Tokenize PGN movetext by stripping move numbers, comments in braces, semicolon comments, and NAG annotations ($1, $2, etc.), then display moves in numbered White-Black pairs
- Drop result tokens (1-0, 0-1, 1/2-1/2, *) automatically so the move list shows only actual moves
- Run entirely client-side: your PGN or FEN input never leaves your browser
How this tool works
The tool has two modes, toggled with the FEN and PGN buttons. In FEN mode, the parser splits the input on whitespace into up to six fields. The first field is the board placement, split on slashes into eight ranks. Each rank is scanned character by character: digits 1 through 8 insert that many empty squares, and letters KQRBNPkqrbnp place pieces. The parser verifies each rank sums to exactly eight squares and reports an error if not. The remaining fields (active color, castling availability, en passant target, halfmove clock, fullmove number) are displayed as labeled text. The board renders as an HTML table with Unicode piece glyphs on alternating light and dark squares.
In PGN mode, the parser first extracts tag pairs using a regex that matches bracketed headers like [White "Magnus Carlsen"]. It then strips all bracketed sections from the text to isolate the movetext. Comments inside braces, semicolon line comments, move numbers (digits followed by dots), and NAG codes (dollar sign plus digits) are removed. The remaining tokens are split on whitespace, and result tokens (1-0, 0-1, 1/2-1/2, *) are filtered out. Moves are then paired into numbered rows showing White and Black moves side by side.
The tool does not validate move legality. It parses notation syntactically and displays it. A move like Nf3 will appear in the list regardless of whether a knight could actually reach f3 from the starting position. For full legality checking, use a chess engine or a library like chess.js.
How FEN and PGN notation work (Steven J. Edwards 1994)
FEN is specified in the PGN Standard, originally documented by Steven J. Edwards in 1994 in the chess programming community. A FEN string has six space-separated fields. The first field encodes piece placement rank by rank from rank 8 down to rank 1, with files a through h left to right. Uppercase letters are White pieces, lowercase are Black. Digits represent consecutive empty squares. The remaining fields are active color (w or b), castling availability (KQkq or a subset, or dash for none), en passant target square (or dash), halfmove clock (moves since last pawn move or capture, for the fifty-move rule), and fullmove number (starts at 1, increments after Black's move).
PGN is also specified in the PGN Standard by Steven J. Edwards (1994). A PGN file has two sections: a tag pair section and a movetext section. Tag pairs are bracketed key-value headers like Event "FIDE World Championship"], [Site "London"], [Date "2023.12.10"], [White "Ding Liren"], [Black "Gukesh D"], [Result "1/2-1/2"]. The movetext section uses Standard Algebraic Notation (SAN), where moves are written as piece letter plus destination square (Nf3, Bb5), with O-O for kingside castling, O-O-O for queenside, and symbols like + for check and # for checkmate. The [FIDE Laws of Chess govern the rules these notations describe.
SAN is the human-readable notation. Long Algebraic Notation (LAN) includes the source square (e2e4 instead of e4). The tool parses SAN movetext, which is what virtually all PGN files use.
How to use this tool
- Select a mode: FEN for decoding a single position string, or PGN for parsing a full game record
- In FEN mode, paste a FEN string like rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1. The tool splits it into six fields and renders the board
- Check the validation output. If a rank does not sum to 8 squares or an invalid character appears, the tool shows an error message identifying the problem
- In PGN mode, paste a complete PGN game including bracketed headers and movetext. The tool extracts headers and tokenizes moves into numbered pairs
- Review the parsed output: headers appear as a key-value list, moves appear as numbered White-Black pairs, and result tokens are stripped automatically
- Copy the decoded output if you need it in plain text format for notes or documentation
Real-world examples
Decoding the starting position FEN
Input: `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`. The tool renders the standard starting board with all pieces on their home squares. Active color is White. Both sides have full castling rights (KQkq). No en passant target. Halfmove clock is 0, fullmove number is 1. This is the FEN every chess database uses as the root position.
Parsing a PGN game with headers
Input: a PGN file starting with `[Event "Casual Game"]` and `[White "Alice"]` and `[Black "Bob"]`, followed by `1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 1/2-1/2`. The tool extracts three headers and displays six moves in three numbered rows. The result token 1/2-1/2 is filtered out of the move list. You see the Ruy Lopez opening in clean algebraic notation.
Reading a middlegame FEN with en passant
Input: `rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2`. The tool shows White's pawn on e4 and Black's pawn on c5. The en passant target is c6, meaning Black just played c7-c5 and White can capture en passant with dxc6. The fullmove number is 2, confirming this is the second move of the game.
Handling PGN with comments and NAGs
Input: `1. e4 {king pawn opening} e5 2. Nf3 $1 Nc6`. The tool strips the braced comment and the NAG annotation ($1) during tokenization. The output shows two clean moves: 1. e4 e5 and 2. Nf3 Nc6. Comments and NAGs are metadata for human readers and are not part of the move sequence.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| FEN | 6 fields, single position | Position sharing, engine analysis, puzzle setup |
| PGN | Headers + SAN movetext, full game | Game databases, tournament records, broadcast |
| EPD | 4 fields, no move clocks | Position testing, engine commands (similar to FEN) |
| LAN | Source + destination square | Unambiguous notation, engine communication |
| SAN | Piece letter + destination | Human-readable, standard PGN movetext |
Limitations or considerations
This tool parses FEN and PGN syntactically. It does not validate move legality. A PGN move like Qxe7 will appear in the output even if no queen can legally reach e7 from the current position. For legality checking, use a library like chess.js or a chess engine such as Stockfish.
The PGN parser handles standard SAN movetext but does not fully resolve ambiguous moves (where disambiguation by file, rank, or both is needed). It displays the raw SAN tokens as written. If a PGN file uses non-standard notation or contains malformed tags, the parser may skip or misinterpret them.
FEN parsing requires at least four fields (board, active color, castling, en passant). Some older FEN variants omit the halfmove and fullmove clocks. The tool defaults these to 0 and 1 respectively when missing, which matches common practice but may not reflect the actual game state.
For solving chess puzzles rather than decoding notation, try the Sudoku Solver for grid-based logic puzzles, the Kakuro Solver for cross-sum puzzles, or the Mastermind Solver for code-breaking deduction games.
Frequently asked questions
What is the difference between FEN and PGN?
FEN describes a single board position with six fields: piece placement, active color, castling rights, en passant target, halfmove clock, and fullmove number. PGN records an entire game with header tags (event, players, date, result) followed by movetext in Standard Algebraic Notation. FEN is a snapshot; PGN is a movie.
Why does FEN list ranks from 8 down to 1?
FEN reads the board from the White player's perspective, starting at the top-left corner (a8) and scanning left to right, top to bottom. Rank 8 is listed first because it is at the top of the board from White's view. This convention comes from the original Forsyth-Edwards notation and is consistent across all chess software.
Does this tool validate that PGN moves are legal?
No. The tool parses notation syntactically and displays moves as written. It does not check whether a move is legal in the current position. For legality validation, use a chess library like chess.js, which maintains board state and rejects illegal moves. This tool is for reading and decoding notation, not for playing chess.
What are NAG codes in PGN?
NAG (Numeric Annotation Glyph) codes are dollar-sign-prefixed numbers in PGN movetext that represent standard annotations. $1 means good move, $2 means mistake, $3 means brilliant move, $4 means blunder. The PGN specification defines over 140 NAG codes. This tool strips them during parsing since they are annotation metadata, not moves.
Can I use this tool to convert FEN to PGN?
No. FEN captures a single position, while PGN records a sequence of moves. You cannot generate a move list from a position without knowing how the game arrived there. To get a PGN from a position, you would need to play moves forward from that position in a chess interface that records them.
Conclusion
FEN and PGN are the two notation formats that make chess portable between engines, databases, and platforms. This decoder turns cryptic strings like `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1` into a visual board and turns PGN files into readable move lists, all in your browser. For other puzzle formats, see the Sudoku Solver, Kakuro Solver, and Mastermind Solver.