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

js.nbt

v1.0.1

Published

A robust, type-safe NBT (Named Binary Tag) library for JavaScript and TypeScript. Parse and serialize NBT data with ease.

Readme

js.nbt

npm version license downloads

A robust, type-safe, and high-performance NBT (Named Binary Tag) library for JavaScript and TypeScript. Designed to be easy to use while providing full control over the NBT format. Supports both CommonJS and ES Modules.

Features

  • 🚀 High Performance: Optimized for speed and low memory usage.
  • 📦 Dual Build: Works seamlessly with CommonJS (require) and ES Modules (import).
  • 🔒 Type-Safe: Written in TypeScript with complete type definitions.
  • 🗜️ Compression Support: Built-in support for Gzip compression/decompression.
  • 🌐 Universal: Works in Node.js and modern environments supporting Buffers.

Installation

npm install js.nbt

Usage

CommonJS (require)

const { parse, writeSync } = require("js.nbt");
const fs = require("fs");

// Reading
const buffer = fs.readFileSync("level.dat");
const nbt = parse(buffer);

// Writing
const newBuffer = writeSync(nbt);

ES Modules / TypeScript (import)

Reading NBT Files

You can read NBT data from a file or buffer. The library automatically detects if the data is Gzipped.

import { parse, parseSync } from "js.nbt";
import * as fs from "fs";

// Async
async function readNbt() {
  const buffer = await fs.promises.readFile("level.dat");
  const nbt = await parse(buffer);
  console.log(nbt);
}

// Sync
const buffer = fs.readFileSync("level.dat");
const nbt = parseSync(buffer);
console.log(nbt);

Writing NBT Files

You can create NBT data structures and serialize them back to a buffer.

import { write, writeSync, ParsedNBT } from "js.nbt";
import * as fs from "fs";

const data: ParsedNBT = {
  name: "MyLevel",
  value: {
    LevelName: "New World",
    SpawnX: 100,
    SpawnY: 64,
    SpawnZ: 100,
    Player: {
      Health: 20.0,
      Inventory: [],
    },
  },
};

// Async (Compressed)
async function saveNbt() {
  const buffer = await write(data, true); // true for Gzip compression
  await fs.promises.writeFile("level.dat", buffer);
}

// Sync (Uncompressed)
const buffer = writeSync(data, false);
fs.writeFileSync("level_uncompressed.dat", buffer);

Type Mapping

The library maps NBT tags to JavaScript types as follows:

| NBT Tag | JavaScript Type | | --------- | --------------- | | Byte | number | | Short | number | | Int | number | | Long | bigint | | Float | number | | Double | number | | ByteArray | Buffer | | String | string | | List | Array | | Compound | Object | | IntArray | Int32Array | | LongArray | BigInt64Array |

API Reference

parse(buffer: Buffer): Promise<ParsedNBT>

Asynchronously parses an NBT buffer. Automatically handles Gzip decompression.

parseSync(buffer: Buffer): ParsedNBT

Synchronously parses an NBT buffer. Automatically handles Gzip decompression.

write(nbt: ParsedNBT, compress?: boolean): Promise<Buffer>

Asynchronously serializes NBT data. Set compress to true to Gzip the output.

writeSync(nbt: ParsedNBT, compress?: boolean): Buffer

Synchronously serializes NBT data. Set compress to true to Gzip the output.

License

MIT