You have a position on a wooden board or on paper, and you want it as a line of text that you can store or paste elsewhere. Writing the FEN yourself is quick once you follow a fixed routine.
You will work through one position rank by rank, check the total of each rank as you go and then add the five short fields that come after the pieces.
Get the board facing the right way
Before writing anything, make sure you know where a1 is. From White's side it is the dark corner on the near left, and rank 8 is the far row. If you are copying a printed picture, check its edge labels, since some are drawn from Black's side. The guide on reading a diagram covers that check.
FEN is written from White's point of view, whoever is to move. You begin at rank 8 and work down to rank 1. Inside each rank you go from the a-file to the h-file, which is left to right as White sees it.
Use uppercase for White (K, Q, R, B, N and P) and lowercase for Black (k, q, r, b, n and p). Here the pawn does get a letter, unlike in written moves. For the purpose of each field, read what FEN is.
r4rk1/pp3ppp/2p5/8/3N4/1P4P1/P4PBP/3R2K1 b - - 0 22Write one rank at a time
Run a finger along the rank, starting at the a-file. When you meet a piece, write its letter. When you meet empty squares, count how many lie together and write that number as a single digit. A run of empty squares ends only at a piece or at the edge of the board, so two digits never stand side by side.
| Rank | From the a-file to the h-file | You write | Total |
|---|---|---|---|
| 8 | rook, four empty, rook, king, one empty | r4rk1 | 1+4+1+1+1 = 8 |
| 7 | two pawns, three empty, three pawns | pp3ppp | 2+3+3 = 8 |
| 6 | two empty, pawn, five empty | 2p5 | 2+1+5 = 8 |
| 5 | eight empty | 8 | 8 |
| 4 | three empty, knight, four empty | 3N4 | 3+1+4 = 8 |
| 3 | one empty, pawn, four empty, pawn, one empty | 1P4P1 | 1+1+4+1+1 = 8 |
| 2 | pawn, four empty, pawn, bishop, pawn | P4PBP | 1+4+1+1+1 = 8 |
| 1 | three empty, rook, two empty, king, one empty | 3R2K1 | 3+1+2+1+1 = 8 |
Look at rank 8 slowly. The black rook on a8 gives the letter r. The squares b8 to e8 are empty, which gives 4. Then come a rook, a king and one last empty square on h8, so the group ends with 1. That final digit is easy to forget.
It helps to write the eight groups on eight separate lines first, labeled from 8 down to 1. A wrong total is then easy to trace before anything is joined.
r4rk1/pp3ppp/2p5/8/3N4/1P4P1/P4PBP/3R2K1 b - - 0 22Join the eight groups with slashes, from the rank 8 group to the rank 1 group, with no spaces and no slash at the end.
Field 1 of the worked position
r4rk1/pp3ppp/2p5/8/3N4/1P4P1/P4PBP/3R2K1
Check that every rank adds to eight
Add up each group before moving on. A letter counts as one square and a digit counts as its number. Any total other than eight means that a square was skipped or counted twice, and the pieces after that point will be shifted.
- There are eight groups, so there are seven slashes.
- Each group totals eight.
- The whole field has exactly one K and one k.
- The first and last groups contain no P and no p.
Next, compare piece counts. The worked position has nine white pieces and pawns and nine black ones, so your field should hold nine uppercase and nine lowercase letters.
Fill in the last five fields
Leave a space after the pieces, then add the other fields in this order, with one space between them.
- Side to move: write w or b.
- Castling: write K, Q, k and q, keeping that order, for each right that remains. Write a hyphen if none remain.
- En passant: if the last move was a pawn advancing two squares, write the square it skipped. Otherwise write a hyphen.
- Halfmove clock: write the number of half moves since the last capture or pawn move.
- Move number: write the number of the move now being played.
For the worked position, Black is to move, neither side can castle and no pawn has just advanced two squares. Say the game is at move 22 and White's last move was a single pawn step, so the clock reads 0.
The complete string
r4rk1/pp3ppp/2p5/8/3N4/1P4P1/P4PBP/3R2K1 b - - 0 22
Do not guess castling rights from the picture alone. A king and rook standing on their starting squares may have moved and come back. If the history is unknown, decide what your exercise needs and write that.
A second example with castling and en passant
In the next position White has a king and one rook at home, Black has a king and both rooks, and a pawn has just advanced two squares.
r3k2r/5ppp/8/8/2P5/8/5PPP/4K2R b Kkq c3 0 18| Field | You write | Reason |
|---|---|---|
| Pieces | r3k2r/5ppp/8/8/2P5/8/5PPP/4K2R | rank 8 down to rank 1 |
| Side to move | b | Black moves next |
| Castling | Kkq | White kingside only, Black both sides |
| En passant | c3 | the square the pawn skipped |
| Halfmove clock | 0 | the last move was a pawn move |
| Move number | 18 | Black's half of move 18 is next |
Build the piece field exactly as before. Its rank 4 group is 2P5: two empty squares, the pawn on c4 and five empty squares. The castling field has no Q because White has no rook left on a1.
No black pawn can capture on c3 here. The PGN standard still has you record the square after a two-square advance. Some programs write a hyphen when no capture exists, so do not be surprised to see either.
Common mistakes while writing
- Starting at rank 1. The ranks come out in reverse order.
- Reading from Black's left. Files run from a to h even if you sit behind the black pieces.
- Splitting one gap into two digits, such as 31 where 4 is meant.
- Dropping a closing digit. Empty squares at the end of a rank count too.
- Wrong case. A lowercase letter is a black piece.
- Stopping after the pieces. Write all six fields.
Final check
- Paste the string into the Board builder and compare it square by square with the original.
- Flip the view if the original was drawn from Black's side.
- Confirm the side to move, castling rights and en passant square.
- Save the position with a title that you will recognize.
If the string will not load, the guide to rejected FENs helps you find the broken part. If you are preparing exercises for a group, check each string before you move on to printing the diagrams.
Common questions
Where do I start when writing a FEN?
At the a-file of rank 8, as White sees the board. Work along that rank, then move down to the next one.
How do I write empty squares in FEN?
Count the empty squares that lie together on one rank and write the number as a single digit from 1 to 8.
What should I write if I do not know the move number?
A common choice is 0 for the halfmove clock and 1 for the move number. The pieces and side to move are unaffected.
Are there spaces between the ranks?
No. Ranks are joined by slashes only. Spaces are used to separate the six fields.
Sources
- Portable Game Notation Specification and Implementation Guide. Coordinated by Steven J. Edwards. Standard algebraic notation (section 8.2.3) and the FEN position format (section 16.1). Consulted on 25 November 2026.