open source · MIT license

See where your
tokens go

You're spending hundreds on structured generation and you have no idea which fields cost what. tokstat reads your JSON corpus, tokenizes every field, and shows you exactly where the money goes.

$ npx tokstat
tokstat circle pack visualization showing per-field token costs

Per-field token economics

$

Cost per field

See exactly how many tokens each field costs — avg, p50, p95 across your entire corpus. Estimated dollar cost per model.

%

Fill rate analysis

Find fields that are null 60%+ of the time. You're paying for the field name and null literal every time — pure waste.

{}

Schema overhead

Field names, braces, brackets, colons, commas — structural tokens you pay for every instance. tokstat shows exactly how much.

[]

Array repetition tax

Arrays of objects repeat every field name per item. 5 items with 8 fields = 40 field names. tokstat quantifies the cost.

Multi-model pricing

Switch between models instantly. Live pricing from OpenRouter. See how costs change from GPT-4o to Claude to Gemini.

Schema cohorts

Mixed-schema corpus? tokstat auto-detects schema variants and lets you analyze them separately or combined.

Four ways to see your data

Area shows relative cost. Click any field to drill into its children. Switch views to spot different patterns.

Treemap Sunburst Circle Pack Icicle
tokstat alternate implementation with circle pack and cohort detection

Automatic insights

tokstat scans your schema and flags the highest-impact optimization opportunities — no manual analysis needed.

cast[].awards[] repeats 3 field names per item × 2.8 items avg, costing 96 tokens in repetition
reviews[].summary is null 35% of the time — making it optional saves 14 tok/instance
box_office is 68% structural overhead — 17 of 25 tokens are field names and braces
genre has 5 unique values across 13 instances — consider replacing with an enum

Try it now

Two implementations, built in parallel. Pick one and explore.