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

tokstat

v0.1.0

Published

Visualize per-field token costs across a corpus of LLM-generated JSON

Readme

tokstat

A beautiful, interactive explorer for the token economics of your LLM-generated JSON.

Point it at a corpus of structured outputs and see exactly where your tokens — and dollars — are going. Treemap, sunburst, circle pack, or icicle chart. Click into any field to drill down. Animated transitions between views. Every interaction designed to make schema auditing something you want to do, not something you have to.

npx tokstat ./data/**/*.json

Bakeoff

This project is currently a bakeoff between two AI coding agents building the same tool from the same spec:

| Branch | Agent | Model | |--------|-------|-------| | claude/tokstat | Claude Code | Opus 4.6 | | codex/tokstat | Codex | GPT 5.3 (high) |

Both start from the same design system, specs, and fixtures. Same requirements, different implementations.

Claude Code (Opus 4.6):

Claude Code implementation — circle pack with thermal colors, sidebar with cohort selector and model combobox

Codex (GPT 5.3 high):

Codex implementation — circle pack with tooltip, schema cohorts, and detail panel

Live demo: tomneyland.github.io/tokstat

What it does

You're running structured generation (OpenAI, Anthropic, Gemini) with JSON schemas. You're spending hundreds or thousands of dollars per run. You have no idea which fields cost what, which optional fields are rarely populated, or whether your 200-character field names are bleeding you dry.

tokstat reads your generated JSON files, walks the schema hierarchy, tokenizes every field name and value, and gives you an interactive visualization of where the weight is.

Per-field analytics:

  • Token count: avg, min, max, p50, p95 across your corpus
  • Fill rate for optional/nullable fields
  • Schema overhead (field names, braces, brackets, colons, commas) vs. value payload
  • Estimated cost per field per model/provider

Multiple visualization modes:

  • Treemap — where is the money going (relative area = relative cost)
  • Sunburst — drill into nested structure radially
  • Circle pack — spot outliers and clustering
  • Icicle — linear depth exploration

Animated transitions between views. Click any node to zoom into that subtree.

Install

npm install -g tokstat
# or
npx tokstat ./path/to/files/**/*.json

Usage

# Point at JSON files
tokstat ./outputs/**/*.json

# Specify model for cost estimation
tokstat ./outputs/**/*.json --model gpt-4o

# JSON output for LLM consumption / CI pipelines
tokstat ./outputs/**/*.json --format json

# LLM-optimized context output
tokstat ./outputs/**/*.json --format llm

Stack

  • Analysis: Node/Bun — file walking, schema inference, tokenization (js-tiktoken)
  • Visualization: Svelte 5 + D3 layouts — reactive rendering with hand-crafted SVG
  • Distribution: npm package, opens local browser. No Electron, no desktop wrapper.

License

MIT