Problem 61155. FEN to Chess Board

Note: This problem is the reverse, or complement, of Problem 61144 - FEN Chess Notation.
Given a FEN (Forsyth-Edwards Notation) string representing a chess board position, convert it to an 8-by-8 character matrix.
FEN notation encodes each rank (row) from top to bottom, separated by slashes (`/`). Numbers 1-8 represent consecutive empty squares.
The output matrix uses:
  • Dots (`.`) for empty squares
  • Letters for pieces: `rnbqkp` (black pieces) and `RNBQKP` (white pieces)
If the FEN string contains additional fields (castling rights, en passant, etc.), ignore everything after the first space and only parse the board position.
Example 1
Starting position.
Input: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR'
Output:
['rnbqkbnr';
'pppppppp';
'........';
'........';
'........';
'........';
'PPPPPPPP';
'RNBQKBNR']
Example 2
After white plays e4:
Input: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR'
Output:
['rnbqkbnr';
'pppppppp';
'........';
'........';
'....P...';
'........';
'PPPP.PPP';
'RNBQKBNR']
Note: The `4P3` means 4 empty squares, then P, then 3 empty squares.

Solution Stats

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Jan 10, 2026

Solution Comments

Show comments

Problem Recent Solvers3

Suggested Problems

More from this Author53

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!