Chess in the browser, for two players or against the computer.
No frameworks, no runtime dependencies, no build step.
Play · Features · Quick start · Keyboard · How it works · Contributing · Sponsor
Playing the computer: four opening moves, a hint, then a look back through the game.
| The full rules. Castling, en passant, promotion, check, mate, stalemate, and every draw rule, checked against published perft counts. | A computer opponent. Three levels, searched in a Web Worker so the board never freezes while it thinks. | Offline and installable. After the first visit it runs with no connection, and it can be installed as an app. |
| Game review. Step through any game, read what the engine makes of each position, and play on from any move. | Keyboard and screen reader friendly. The board is an ARIA grid, every move is announced, and ? lists every shortcut. |
Nothing to install. Open index.html. No framework, no bundler, no runtime packages: about 7,000 lines of plain JavaScript. |
|
Playing
|
Reviewing
|
|
Saving and sharing
|
Looks and access
|
On the clock against the computer (left); reviewing a game in the light theme with Settings open (right).
Play online: tmhsdigital.github.io/Static_Chess. Nothing to sign up for.
Run it locally:
git clone https://github.com/TMHSDigital/Static_Chess.git
cd Static_Chess
# then open index.html in a browserOpening the file directly is enough to play. Offline mode and installing as an app need the page served over http(s), so for those use any static server:
npx serve . # or: python -m http.serverHost your own copy: fork the repo and turn on GitHub Pages (Settings → Pages → Deploy from branch main, folder / (root)). Any static host works; there is nothing to build. _config.yml keeps docs, tests and tooling out of the published site, so a new top-level file that is not part of the game belongs on that list.
Press ? in the game to see this list. The panel is built from the same table the key handlers read, so it is always up to date.
| Where | Keys | Action |
|---|---|---|
| Board | ← ↑ → ↓ | Move between squares |
| Board | Enter / Space | Pick up or move a piece |
| Moves | ← / → | Previous / next move |
| Move History | Home / End | Starting position / latest move |
| Moves | Esc | Return to the live game |
| Game | Ctrl+Y / Ctrl+Shift+Z | Redo an undone move (Cmd on a Mac) |
| Promotion | Arrow keys / Tab | Move between the pieces to choose |
| Dialogs | Esc | Close a dialog or cancel a promotion |
| Anywhere | ? | Open the keyboard shortcuts |
flowchart LR
main[main.js] --> game[game.js<br/>state and move flow]
game --> rules[rules.js<br/>legal moves, check, draws]
game --> board[board.js<br/>board rendering, keys]
game --> ui[game-ui.js<br/>status, clocks, move list, dialogs]
game --> store[game-store.js<br/>saved and past games]
game --> bridge[engine-bridge.js]
bridge -->|postMessage| worker[ai-worker.js] --> ai[ai.js<br/>alpha-beta search]
ai --> rules
- Rules as pure functions.
rules.jsgenerates legal moves and detects check, mate and draws without touching the page, and the tests check it against published perft counts. - The engine runs off the main thread.
ai.jsis an alpha-beta search with a quiescence search for captures. Easy looks one half-move ahead and sometimes blunders. Medium looks two ahead. Hard deepens iteratively, up to eight half-moves, for about a second. It runs in a Web Worker, and on the page if no worker is available. - One direction of data.
game.jsowns the state and tellsboard.jsandgame-ui.jswhat to show in plain values. Neither of them changes the game. - Offline by design.
sw.jscaches the app files on first visit, andmanifest.webmanifestmakes it installable.
The full picture is in docs/ARCHITECTURE.md.
Project structure
Static_Chess/
├── index.html, 404.html # The page, and GitHub Pages' not-found page
├── sw.js # Service worker: the offline copy
├── manifest.webmanifest # Makes the page installable
├── _config.yml # What GitHub Pages leaves out of the site
├── css/ # style.css, board.css, pieces.css
├── js/
│ ├── config.js # Settings, time controls, themes, key bindings
│ ├── rules.js # Rules of chess, no DOM
│ ├── pieces.js, utils.js # Piece definitions and helpers
│ ├── game.js # The live game: state, move flow, undo, saving
│ ├── board.js, drag.js # Board rendering, keyboard, drag and drop
│ ├── game-ui.js # Status, buttons, clocks, move list, dialogs
│ ├── promotion.js # Promotion chooser
│ ├── notation.js # SAN, PGN and FEN
│ ├── clock.js, review.js # Clock rules; engine scores in words
│ ├── saved-game.js, game-store.js # Checking and storing games
│ ├── engine-bridge.js # Talks to the engine
│ ├── ai.js, ai-worker.js # The computer opponent and its worker
│ └── main.js # Start-up
├── assets/ # Piece SVGs, icons, screenshots, social card
├── tests/ # Jest unit and integration tests, Playwright smoke tests
├── docs/ # Architecture, roadmap, release process
└── releases/ # Release notes
Node is only needed for the dev tooling (22.22.2+ on the 22 line, or 24.15+). The game itself has no dependencies.
npm ci
npm run lint # ESLint, no warnings allowed
npm run format # Prettier check
npm test # Jest unit and integration tests (jsdom)
npm run coverage # The same, with coverage, as CI runs it
npm run test:browser # Chromium smoke tests with PlaywrightCI runs all of these on Node 22 and 24 for every push and pull request. See CONTRIBUTING for the conventions, including what to update when a file is added (for example the service worker's file list).
Next up: a stronger engine (faster move generation, a transposition table), deeper game analysis, named saved games, and more difficulty levels. See docs/ROADMAP.md and the CHANGELOG.
Contributions are welcome, from typo fixes to engine work.
- Look at the open issues. Many include the files involved and acceptance criteria.
- Fork, branch, and make your change with tests.
- Run
npm run lint && npm run format && npm run coverage. - Add a line to
CHANGELOG.mdunder Unreleased if a player would notice the change, then open a pull request.
For larger changes, open an issue first. Please follow the Code of Conduct, and report vulnerabilities privately as described in the Security Policy.
Static Chess is free, has no ads and no tracking. If you enjoy it, you can help keep it maintained:
Starring the repo, reporting a bug, or sharing a game link helps too.
Apache License 2.0 © TMHSDigital