My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UsingFen  
Using a FEN string in a URL to draw a board image
Updated Nov 21, 2009 by seddin...@gmail.com

A FEN string consists of letters, numbers, and slashes. It contains no spaces.

Lower-case letters indicate black pieces: p, r, n, b, q, and k are the pawn, rook, knight, bishop, queen, and king. Upper-case letters indicate white pieces: P, R, N, B, Q, and K. A digit indicates unoccupied squares. For example, the digit 3 indicates 3 successive unoccupied squares.

Starting with the 8th rank, you simply list the pieces and unoccupied squares in order, left-to-right. Ranks are separated by the forward slash.

A complete FEN string also includes game information such as the move number, who’s on the move, castling privileges, etc. Chess Imager, though, only uses the position information as described above.

Here’s the FEN string for the starting position:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR/

To generate a board image, append the FEN string to the URL pointing to the ChessImager.php script location as follows:

http://www.eddins.net/steve/chess/ChessImager/ChessImager.php?fen=
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR/

The URL above generates this image:

Here's the URL for the position after 1. e4 c5:

http://www.eddins.net/steve/chess/ChessImager/ChessImager.php?fen=
rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR

Here's the resulting image:

Comment by misterio...@gmail.com, Oct 7, 2010

FEN: 1r3r2/1b2q1kp/1p1p2p1/p4p2/P1PNn3/1PR4P/3Q1PP1/3BR1K1 w


Sign in to add a comment
Powered by Google Project Hosting