Installation
Install Chessalyzer and import the modules you need.
Chessalyzer runs on any JavaScript runtime, with Node.js ≥ 22 or Bun being recommended. There are no other requirements, and the library itself has zero dependencies.
npm install chessalyzerWhat you can import
The main entry point is chessalyzer, with a few extra subpaths for the parts you only need sometimes:
import { analyzePGN } from 'chessalyzer';
import { tileTracker, printHeatmap } from 'chessalyzer/trackers';
import { parsePGN, streamParsePGN } from 'chessalyzer/pgn';| Subpath | What you'll find there |
|---|---|
chessalyzer | analyzePGN, error helpers, analysis types |
chessalyzer/trackers | Built-in trackers, tracker authoring, heatmaps |
chessalyzer/pgn | Parse-only PGN access (parsePGN, streamParsePGN) |
chessalyzer/board | Square and coordinate helpers, piece-name types |
chessalyzer/replay | Replay action types (Action, …) |
Don't worry about memorizing these — the guides always show the right import at the top of each example.
Basic usage
If you have a PGN file lying around, this is a complete parse + analyze run:
import { analyzePGN } from 'chessalyzer';
import { tileTracker } from 'chessalyzer/trackers';
const tiles = tileTracker();
const result = await analyzePGN('games.pgn', { trackers: [tiles] });
console.log(result.gameCount, result.moveCount);
console.log(tiles.state.movesTotal);No PGN file yet? The next page comes with a tiny one you can copy — let's run your first real analysis.