# jhlywa/chess.js

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jhlywa-chess-js).**

4,257 stars · 977 forks · TypeScript · bsd-2-clause

## Links

- GitHub: https://github.com/jhlywa/chess.js
- Homepage: http://jhlywa.github.io/chess.js/
- awesome-repositories: https://awesome-repositories.com/repository/jhlywa-chess-js.md

## Topics

`chess`

## Description

chess.js is a headless chess game logic engine and move validation library. It functions as a board state manager that enforces official rules, generates legal moves, and tracks game state without a user interface.

The project provides comprehensive parsing and management for standard chess notations, including PGN for game histories and FEN for board configurations. It includes utilities for importing and exporting game records, managing PGN metadata, and handling position annotations.

The engine covers a wide range of analysis capabilities, such as detecting game-ending conditions like checkmate and stalemate, performing square control analysis, and calculating piece positions. It supports move execution and reversion, move history tracking, and board position hashing for rapid configuration comparison.

The library is implemented in TypeScript.

## Tags

### Game Development

- [Chess Board State Managers](https://awesome-repositories.com/f/game-development/chess-board-state-managers.md) — Ships a headless chess board state manager that tracks piece placements and game conditions.
- [Chess Game Engines](https://awesome-repositories.com/f/game-development/chess-game-engines.md) — An engine that enforces official chess rules, generates legal moves, and tracks game state without a user interface.
- [ASCII Board Renderers](https://awesome-repositories.com/f/game-development/ascii-board-renderers.md) — Generates text-based visual representations of the board for debugging and display. ([source](https://jhlywa.github.io/chess.js/v1.0.0-beta.7/))
- [Board State Queries](https://awesome-repositories.com/f/game-development/ascii-board-renderers/board-state-queries.md) — Ships multiple methods to query the board state in array, diagram, and FEN formats. ([source](https://cdn.jsdelivr.net/gh/jhlywa/chess.js@master/README.md))
- [Board State Manipulators](https://awesome-repositories.com/f/game-development/board-state-manipulators.md) — Provides utilities for manually altering piece placements and board configurations. ([source](https://jhlywa.github.io/chess.js/v0.13.2/))
- [Board Reset Utilities](https://awesome-repositories.com/f/game-development/board-state-manipulators/board-reset-utilities.md) — Provides a function to reset the board to the standard starting position. ([source](https://jhlywa.github.io/chess.js/v0.12.0/))
- [Piece Placement Modifiers](https://awesome-repositories.com/f/game-development/board-state-manipulators/piece-placement-modifiers.md) — Provides validated piece placement on individual squares for board setup. ([source](https://jhlywa.github.io/chess.js/v0.11.0/))
- [Piece Removal Utilities](https://awesome-repositories.com/f/game-development/board-state-manipulators/piece-removal-utilities.md) — Provides piece removal from individual squares for board manipulation. ([source](https://jhlywa.github.io/chess.js/v0.11.0/))
- [Castling Rights Managers](https://awesome-repositories.com/f/game-development/castling-rights-managers.md) — Provides configuration of castling rights for each color in the chess game. ([source](https://jhlywa.github.io/chess.js/v1.3.0/))
- [Check and Checkmate Detectors](https://awesome-repositories.com/f/game-development/check-and-checkmate-detectors.md) — Detects check and checkmate conditions for the side to move in the chess game. ([source](https://jhlywa.github.io/chess.js/v1.3.0/))
- [Chess Game Logic Engines](https://awesome-repositories.com/f/game-development/chess-game-logic-engines.md) — Implements detection of check, checkmate, stalemate, and draw conditions for chess analysis.
- [Chess Move Validation Libraries](https://awesome-repositories.com/f/game-development/chess-move-validation-libraries.md) — Verifies the legality of chess moves according to official game rules.
- [Chess Notation Parsers](https://awesome-repositories.com/f/game-development/chess-notation-parsers.md) — Parses and generates standard chess notations like FEN and PGN for game records.
- [Game End State Detectors](https://awesome-repositories.com/f/game-development/game-end-state-detectors.md) — Implements rule-based detection of draw conditions including the fifty-move rule and insufficient material. ([source](https://jhlywa.github.io/chess.js/v1.3.0/))
- [Game Notation Export](https://awesome-repositories.com/f/game-development/game-notation-export.md) — Load a board state from a FEN string or PGN notation, and export the current game as FEN or PGN. ([source](https://jhlywa.github.io/chess.js/v0.13.2/))
- [Legal Move Generators](https://awesome-repositories.com/f/game-development/legal-move-generators.md) — Generates all legal chess moves by applying piece-specific patterns and filtering against check constraints.
- [Move Execution Systems](https://awesome-repositories.com/f/game-development/move-execution-systems.md) — Provides move execution systems that apply legal chess moves to the board state. ([source](https://jhlywa.github.io/chess.js/v0.10.2/))
- [Move History Stacks](https://awesome-repositories.com/f/game-development/move-history-stacks.md) — Maintains a stack of move objects enabling undo of the last half-move to explore alternative variations.
- [Move History Tracking](https://awesome-repositories.com/f/game-development/move-history-tracking.md) — Records a chronological sequence of moves to enable state restoration and game review.
- [Move Reversion Systems](https://awesome-repositories.com/f/game-development/move-reversion-systems.md) — Ships move reversion systems to undo game moves and restore previous board states. ([source](https://cdn.jsdelivr.net/gh/jhlywa/chess.js@master/README.md))
- [Move Validation Engines](https://awesome-repositories.com/f/game-development/move-validation-engines.md) — Validates moves in Standard Algebraic Notation and executes them if legal. ([source](https://jhlywa.github.io/chess.js/v0.10.0/))
- [FEN Configuration Parsers](https://awesome-repositories.com/f/game-development/open-source-games/genres/board-games/fen-configuration-parsers.md) — Encodes and decodes complete board configurations using Forsyth-Edwards Notation strings.
- [FEN Managers](https://awesome-repositories.com/f/game-development/open-source-games/genres/board-games/fen-configuration-parsers/fen-managers.md) — Initialize, load, or export board positions using Forsyth-Edwards Notation (FEN) strings, with optional validation skipping. ([source](https://jhlywa.github.io/chess.js))
- [PGN Notation Managers](https://awesome-repositories.com/f/game-development/pgn-notation-managers.md) — Stores and retrieves move sequences and metadata using the Portable Game Notation format. ([source](https://jhlywa.github.io/chess.js/v0.10.0/))
- [Piece Position Querying](https://awesome-repositories.com/f/game-development/piece-position-querying.md) — Provides utilities for retrieving piece locations and identifying which piece occupies a given square. ([source](https://jhlywa.github.io/chess.js))
- [Piece Placement Modifiers](https://awesome-repositories.com/f/game-development/piece-position-querying/piece-placement-modifiers.md) — Provides validated piece placement and removal on individual squares for board setup. ([source](https://jhlywa.github.io/chess.js))
- [Piece Placement Validators](https://awesome-repositories.com/f/game-development/piece-position-querying/piece-placement-validators.md) — Provides validated piece placement on squares, enforcing rules like preventing duplicate kings. ([source](https://jhlywa.github.io/chess.js/v1.0.0-beta.1/))
- [Piece Removal Utilities](https://awesome-repositories.com/f/game-development/piece-position-querying/piece-removal-utilities.md) — Provides piece removal from individual squares for board manipulation. ([source](https://jhlywa.github.io/chess.js/v1.0.0-beta.1/))
- [Position Setup Utilities](https://awesome-repositories.com/f/game-development/piece-position-querying/position-setup-utilities.md) — Provides initialization of board positions from FEN strings and manual piece placement. ([source](https://jhlywa.github.io/chess.js/v1.3.1/))
- [Square Control Analyzers](https://awesome-repositories.com/f/game-development/square-control-analyzers.md) — Provides algorithms to determine which pieces attack or control specific squares on the board. ([source](https://cdn.jsdelivr.net/gh/jhlywa/chess.js@master/README.md))
- [Board State Inspectors](https://awesome-repositories.com/f/game-development/ascii-board-renderers/board-state-inspectors.md) — Returns board state in multiple formats and detects check, checkmate, and draw conditions. ([source](https://jhlywa.github.io/chess.js/v0.13.2/))
- [Board State Inspectors](https://awesome-repositories.com/f/game-development/board-state-manipulators/board-state-inspectors.md) — Retrieves pieces, square colors, castling rights, and 2D array representations of the board. ([source](https://jhlywa.github.io/chess.js/v0.13.3/))
- [Turn Managers](https://awesome-repositories.com/f/game-development/move-validation-engines/turn-managers.md) — Manages which side moves next, enforcing turn-based play rules. ([source](https://cdn.jsdelivr.net/gh/jhlywa/chess.js@master/README.md))

### Artificial Intelligence & ML

- [Stalemate Detectors](https://awesome-repositories.com/f/artificial-intelligence-ml/game-element-detection/stalemate-detectors.md) — Reports whether the side to move has been stalemated. ([source](https://jhlywa.github.io/chess.js/v1.0.0-beta.1/))
- [Threefold Repetition Detectors](https://awesome-repositories.com/f/artificial-intelligence-ml/game-element-detection/threefold-repetition-detectors.md) — Implements threefold repetition detection as a standard draw condition in chess. ([source](https://jhlywa.github.io/chess.js/v0.10.0/))

### Networking & Communication

- [Check and Checkmate Status Detectors](https://awesome-repositories.com/f/networking-communication/messaging-channel-management/autopilot-status-checks/check-and-checkmate-status-detectors.md) — Reports check, checkmate, and stalemate status for the current player. ([source](https://jhlywa.github.io/chess.js/v0.10.1/))

### Programming Languages & Runtimes

- [Stalemate and Repetition Detectors](https://awesome-repositories.com/f/programming-languages-runtimes/class-method-definitions/instance-methods/static-or-instance-method-checks/stalemate-and-repetition-detectors.md) — Detects stalemate and threefold repetition, key draw conditions in chess. ([source](https://jhlywa.github.io/chess.js/v1.3.0/))

### Software Engineering & Architecture

- [Board Array Representations](https://awesome-repositories.com/f/software-engineering-architecture/board-position-hashing/board-array-representations.md) — Provides a method to retrieve the board as a two-dimensional array for programmatic access. ([source](https://jhlywa.github.io/chess.js/v0.12.0/))
- [Board Reset Utilities](https://awesome-repositories.com/f/software-engineering-architecture/board-position-hashing/board-reset-utilities.md) — Provides a function to reset the board to the standard starting position. ([source](https://jhlywa.github.io/chess.js/v0.10.0/))
- [FEN Position Loaders](https://awesome-repositories.com/f/software-engineering-architecture/board-position-hashing/board-reset-utilities/fen-position-loaders.md) — Set up the board from a FEN string, resetting castling rights, en passant square, and move counters. ([source](https://jhlywa.github.io/chess.js/v1.0.0-beta.1/))
- [Board Notation Validation](https://awesome-repositories.com/f/software-engineering-architecture/expression-transformers/notation-converters/board-notation-validation.md) — Parse a Forsyth-Edwards Notation string and return whether the board setup is valid or list any errors found. ([source](https://jhlywa.github.io/chess.js/v0.12.0/))
- [Move Notation Parsing](https://awesome-repositories.com/f/software-engineering-architecture/expression-transformers/notation-converters/move-notation-parsing.md) — Parses Standard Algebraic Notation and variants into structured move objects for execution.
- [Board Position Hashing](https://awesome-repositories.com/f/software-engineering-architecture/board-position-hashing.md) — Generates unique 64-bit hashes for board positions to enable rapid comparison and repetition detection. ([source](https://jhlywa.github.io/chess.js/v1.3.0/))
- [Position Hashing](https://awesome-repositories.com/f/software-engineering-architecture/string-hashing-techniques/position-hashing.md) — Computes unique 64-bit hashes for board positions to enable fast repetition detection and comparison.
- [Type-Safe Game State Definitions](https://awesome-repositories.com/f/software-engineering-architecture/typescript-type-definitions/type-safe-game-state-definitions.md) — Uses TypeScript's type system to enforce chess-specific invariants like move structures and piece types.

### System Administration & Monitoring

- [Stalemate Status Detectors](https://awesome-repositories.com/f/system-administration-monitoring/task-status-monitors/test-status-trend-tracking/status-change-detection/stalemate-status-detectors.md) — Returns whether the side to move has been stalemated. ([source](https://jhlywa.github.io/chess.js/v0.10.1/))

### User Interface & Experience

- [Board State Visualizers](https://awesome-repositories.com/f/user-interface-experience/board-state-visualizers.md) — Displays board configurations using text-based diagrams and standard notation. ([source](https://jhlywa.github.io/chess.js/v0.12.0/))
