{
 "kind": "tool",
 "slug": "chess-js",
 "path": "tools/chess-js/",
 "name": "chess.js",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Game development",
   "tools/game-dev/"
  ]
 ],
 "lead": "Chess move generation, validation and game state in JavaScript.",
 "chips": [
  {
   "label": "Game development",
   "path": "tools/game-dev/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install chess.js"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/jhlywa/chess.js"
  },
  {
   "label": "Website",
   "href": "https://github.com/jhlywa/chess.js"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "BSD-2-Clause",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/jhlywa/chess.js"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Aug 11, 2026",
   "note": "Latest GitHub release Jun 14, 2025. ",
   "src": "https://github.com/jhlywa/chess.js"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "5 projects",
   "status": "info",
   "sub": "#4 of 8 in its category",
   "note": "Dependency in 5 public GitHub projects set up for AI coding agents that we scanned (0.1%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What chess.js does",
   "parts": [
    {
     "t": "prose",
     "text": "chess.js is a headless chess rules library: it generates and validates moves, reads and writes FEN and PGN, and detects check and game end, which the README sums up as \"basically everything but the AI.\""
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "chess.js popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "50",
       "of": "/ 100",
       "l": "Gid Score, #1962 overall"
      },
      {
       "n": "473K",
       "l": "downloads a week, npm"
      },
      {
       "n": "4,461",
       "l": "GitHub stars"
      },
      {
       "n": "5",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How chess.js is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "chess.js joined the catalog on its public numbers (473,327 downloads a week on npm and 4,461 GitHub stars), not on our project count: it is a dependency in 17 public GitHub projects of our scan, 5 of them set up for AI coding agents.",
      "Projects that use it most often also use Three.js (41.2%), React Three Fiber (29.4%), React (58.8%)."
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 41.2% of its projects",
       "v": "Three.js",
       "path": "tools/three/"
      },
      {
       "l": "In 29.4% of its projects",
       "v": "React Three Fiber",
       "path": "tools/react-three/"
      },
      {
       "l": "In 58.8% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 23.5% of its projects",
       "v": "ws",
       "path": "tools/ws/"
      },
      {
       "l": "In 70.6% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 52.9% of its projects",
       "v": "ESLint",
       "path": "tools/eslint/"
      },
      {
       "l": "In 17.6% of its projects",
       "v": "better-sqlite3",
       "path": "tools/better-sqlite3/"
      },
      {
       "l": "In 17.6% of its projects",
       "v": "Phaser",
       "path": "tools/phaser/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "chess.js in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Permissive move parser is the default",
       "v": "Out of the box, <code>move()</code> notation is read by a permissive parser. It accepts plain SAN like <code>Nf3</code> and also variants such as <code>g1f3</code>, <code>g1-f3</code> and <code>Ng1xf3</code>."
      },
      {
       "l": "Constructor validates FEN",
       "v": "<code>new Chess(fen)</code> throws if the FEN string is invalid. Setting <code>skipValidation</code> turns that off. The docs use it to load a position with the white king missing."
      },
      {
       "l": "attackers() for square control",
       "v": "<code>attackers(square)</code> lists the squares whose pieces can attack a given square. It defaults to the side to move, and an optional color argument switches sides."
      },
      {
       "l": "Position as a 2D array",
       "v": "<code>board()</code> returns the position as nested arrays of <code>{square, type, color}</code> objects, with <code>null</code> for empty squares. That shape maps directly onto a rendered grid."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "No AI",
       "v": "The README lists what the library covers and ends with \"basically everything but the AI.\" Its own example game picks moves at random."
      },
      {
       "l": "Headless, bring your own board",
       "v": "The library includes no user interface elements. The docs mention chessboard.js as the library many developers have integrated it with."
      },
      {
       "l": "Strict parser rejects variants",
       "v": "The second parser accepts only Standard Algebraic Notation that \"strictly adhere[s] to the specification.\" The docs say it \"runs slightly faster but will not parse any non-standard notation.\""
      }
     ]
    },
    {
     "t": "h3",
     "text": "Play a random game and print the PGN"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Ts",
       "code": "import { Chess } from 'chess.js'\n\nconst chess = new Chess()\n\nwhile (!chess.isGameOver()) {\n  const moves = chess.moves()\n  const move = moves[Math.floor(Math.random() * moves.length)]\n  chess.move(move)\n}\nconsole.log(chess.pgn())"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about chess.js",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "three: 3D rendering",
        "@react-three: React Three Fiber packages",
        "better-sqlite3: SQLite driver",
        "esbuild: Bundler",
        "react-router-dom: React routing",
        "ws: WebSocket library"
       ]
      },
      {
       "title": "More in Game development",
       "path": "tools/game-dev/",
       "items": [
        {
         "text": "Phaser",
         "path": "tools/phaser/"
        },
        {
         "text": "Pygame",
         "path": "tools/pygame/"
        },
        {
         "text": "Matter.js",
         "path": "tools/matter-js/"
        },
        {
         "text": "phaser3-rex-plugins",
         "path": "tools/phaser3-rex-plugins/"
        },
        {
         "text": "Colyseus",
         "path": "tools/colyseus/"
        },
        {
         "text": "pyglet",
         "path": "tools/pyglet/"
        },
        {
         "text": "PyBullet",
         "path": "tools/pybullet/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "chess.js",
       "me": true,
       "facts": [
        "BSD-2-Clause",
        "Gid 50",
        "473K/wk"
       ]
      }
     ],
     "more": "Compare chess.js with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install chess.js"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## chess.js\n- Install with `npm install chess.js`. Import with `import { Chess } from 'chess.js'`, or `const { Chess } = require('chess.js')` in CommonJS.\n- chess.js covers \"everything but the AI\" and has no UI. Do not look in it for move evaluation or rendering code.\n- `new Chess(fen)` throws on an invalid FEN, so catch errors when the FEN comes from outside. Pass `{ skipValidation: true }` only when you mean to load an invalid position.\n- Drive a game with `isGameOver()`, `moves()` and `move()`. Serialize with `fen()` or `pgn()`.\n- The default move parser is permissive. The strict parser accepts only spec-compliant SAN.\n- Do not read `getCastlingRights()` as \"castling is legal now\". The docs say checks and other factors also apply.\n- Pass `forceEnpassantSquare` to `fen()` when the output must always include the en passant square.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm chess.js"
  ],
  [
   "Category",
   "Game development"
  ],
  [
   "License",
   "BSD-2-Clause"
  ],
  [
   "Latest version",
   "v1.4.0, June 14, 2025"
  ],
  [
   "On GitHub since",
   "December 2008"
  ],
  [
   "Gid Score",
   "50.1"
  ],
  [
   "Rank in category",
   "#4 of 8"
  ],
  [
   "GitHub",
   "jhlywa/chess.js"
  ],
  [
   "Last change",
   "Aug 11, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/jhlywa.png"
}