A fully-functional chess game that runs in your web browser. Play chess with a beautiful interface, drag-and-drop pieces, and full rule enforcement.
- Full chess rules implementation: All standard chess rules including castling, en passant, and pawn promotion
- Interactive gameplay: Click or drag-and-drop pieces to make moves
- Visual feedback: Highlights valid moves and selected pieces
- Move validation: Only legal moves are allowed
- Check and checkmate detection: Automatically detects check, checkmate, and stalemate
- Move history: View all moves made in algebraic notation
- Captured pieces: See all captured pieces for both sides
- FEN notation: View the current position in FEN format
- Undo moves: Take back your last move
- Flip board: View the board from either player's perspective
Simply open the index.html file in any modern web browser:
- Navigate to the
webdirectory - Double-click
index.htmlor right-click and select "Open with Browser" - The game will load and you can start playing immediately
Alternatively, you can serve it with a local web server:
# Using Python 3
python3 -m http.server 8000
# Using Node.js with npx
npx http-server
# Then open http://localhost:8000 in your browserThere are two ways to move pieces:
-
Click to Move:
- Click on a piece to select it
- Valid moves will be highlighted with green dots
- Click on a highlighted square to move the piece
-
Drag and Drop:
- Click and hold on a piece
- Drag it to the destination square
- Release to drop and make the move
- New Game: Start a fresh game (resets the board)
- Undo Move: Take back the last move
- Flip Board: Rotate the board 180 degrees
- Castling: Click the king and then click on the castling square (two squares left or right)
- En Passant: Automatically available when conditions are met
- Pawn Promotion: Pawns automatically promote to queens when reaching the last rank
The sidebar shows:
- Current Turn: Which player's turn it is
- Game Status: Active, Check, Checkmate, or Stalemate
- Move Count: Total number of moves made
- Move History: List of all moves in algebraic notation
- FEN Position: Current board position in Forsyth-Edwards Notation
- Captured Pieces: Pieces captured by each player
This game works in all modern web browsers:
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
- Opera (latest)
index.html- Main HTML structurestyle.css- Styling and layoutchess-engine.js- Chess game logic and rulesgame.js- UI controller and event handling
The game is built with:
- Pure vanilla JavaScript (no dependencies)
- HTML5 drag-and-drop API
- CSS Grid for board layout
- Unicode chess piece symbols
All chess rules are implemented including:
- Legal move generation for all pieces
- King safety checks
- Castling rights tracking
- En passant target square
- Check, checkmate, and stalemate detection
- FEN notation generation
This game runs entirely in your browser with no internet connection required. All files are local and there are no external dependencies.
- Valid moves are shown with green circles when you select a piece
- Potential captures are highlighted with a red overlay
- The game prevents illegal moves automatically
- You cannot move into check
- The game will alert you when checkmate or stalemate occurs
Enjoy playing chess!