npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pgnpack

v0.4.0

Published

Ultra-compact PGN compression into Base64URL strings using bit-level encoding and optimized move ordering

Readme

pgnpack

Warning: This software is in early development. The encoding algorithm may change and break compatibility. Wait for version 1.0.0 to stabilize.

Ultra-compact PGN compression into Base64URL strings using bit-level encoding and optimized move ordering.

Features

  • PGN compression using legal move indexing
  • Tag filtering support (e.g., [Event], [White], [Black])
  • Annotations and NAG support
  • URL-safe output
  • TypeScript support
  • Dual chess library support: Works with either chess.js or chessops

Install

npm install pgnpack

Peer Dependencies

pgnpack requires one of the following chess libraries (optional peer dependencies):

# Option 1: Install chessops (preferred)
npm install chessops

# Option 2: Install chess.js
npm install chess.js

# Or both - pgnpack will auto-detect and prefer chessops
npm install chessops chess.js

Generate Docs

npm run docs

Open docs/index.html to view.

Example

import { encodePGN, decodePGN } from "pgnpack"

const pgn = `1. e4 e5 2. Nf3 Nc6`

const code = await encodePGN(pgn)
console.log(code) // Compact base64url string

console.log(await decodePGN(code))

// With tags and annotations
const pgnWithMeta = `[Event "Test"]
[White "Player1"]
[Black "Player2"]

1. e4 e5 {Great opening} 2. Nf3`

const fullCode = await encodePGN(pgnWithMeta, {
  tags: ["Event", "White", "Black"],
  annotations: true
})

console.log(await decodePGN(fullCode))
// [Event "Test"]
// [White "Player1"]
// [Black "Player2"]
//
// 1. e4 e5 {Great opening} 2. Nf3

// Using explicit chess adapter (better for repeated calls)
import { createChessJsAdapter, encodePGNWith, decodePGNWith } from "pgnpack"

const chess = await createChessJsAdapter()
const code2 = await encodePGNWith(chess, pgn)
console.log(await decodePGNWith(chess, code2))

API

encodePGN(pgn, options)

Encodes a PGN string into a compact base64url string.

Parameters:

  • pgn: string - PGN string
  • options?: EncodeOptions - Encoding options

EncodeOptions:

interface EncodeOptions {
  tags?: boolean | string[]   // Tags to include: true for all, false for none (by default), or array like ["Event", "White"]
  annotations?: boolean   // Include move annotations and NAGs (default: false)
}

decodePGN(code)

Decodes a compact base64url string back to PGN.

Parameters:

  • code: string - Encoded base64url string

Returns: PGN string (with tags and annotations if they were encoded)

Future Work

  • RAV (Recursive Annotation Variation) support: Add support for encoding/decoding PGN files containing RAV (variations indicated by parentheses). Currently, RAV variations are stripped during encoding.

  • Efficient compression for meaningful annotations: Add more efficient compression for meaningful annotations (i.e. evals, clocks). Currently, annotations are compressed using lz-string, but specialized encoding for structured data like evaluation scores and clock times could improve compression ratios.

Contributing

See CONTRIBUTING.md for detailed instructions on setting up the development environment, testing, and the versioning workflow.

Third-Party Software

pgnpack uses the following third-party libraries:

chessops

Chess and chess variant rules and operations in TypeScript.

chess.js

A JavaScript chess library. Used as a fallback when chessops is not available.

lz-string

LZ-based compression algorithm for JavaScript

License

MIT