TypeScript BSD-2-Clause

chess.js

A TypeScript chess library for chess move generation/validation, piece placement/movement, and check/checkmate/draw detection

J

jhlywa

Dernière activité 11 août 2026
jhlywa/chess.js

4,4 k

étoiles

987

forks

46

issues ouvertes

chess

Ce README est souvent en anglais.

logo

chess.js

GitHub Workflow Status npm npm

chess.js is a TypeScript chess library used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection - basically everything but the AI.

chess.js has been extensively tested in node.js and most modern browsers.

Documentation

This README provides a quick example, full documentation can be found at https://jhlywa.github.io/chess.js.

Installation

Run the following command to install the most recent version of chess.js from NPM:

npm install chess.js

Example Code

The code below plays a random game of chess:

import { Chess } from 'chess.js'

const chess = new Chess()

while (!chess.isGameOver()) {
  const moves = chess.moves()
  const move = moves[Math.floor(Math.random() * moves.length)]
  chess.move(move)
}
console.log(chess.pgn())

Contributing

If you have any questions, suggestions, or find any bugs please open an issue. PRs are very welcome too, please read the Contributing Guide first to help make it a smooth process.

Projets similaires

chess library for legal move generation, FEN/PGN parsing and more

Javachess-legal-moveschess-librarychessboard
Bbhlangonijr
295 étoiles92

Mobile/Web chess UI for lichess.org

TypeScriptboardchesslichess
Llichess-org
1,4 k étoiles333

A chess library for Python, with move generation and validation, PGN parsing and writing, Polyglot opening book reading, Gaviota tablebase probing, Syzygy tablebase probing, and UCI/XBoard engine communication

Pythonchessepdfen
Nniklasf
2,9 k étoiles588