Free Rust engine. Paid profiles planned.
The same JSON. A representation for your model.
Tokendoo compresses your JSON locally, with a lossless round trip over its values. The engine and its reference tables are free. The planned service will offer model-specific profiles with compression settings, comprehension evaluations and version tracking.
median token ratio, cl100k, derived alphabet, shipping fixtures
Wire ratio: compressed payload alone. The format legend adds 97 to 174 tokens and can erase the gain on small payloads.
published synthetic corpus · exact cl100k_base counts · 2026-08-07
01 / The problem
JSON pays for structure, over and over.
A 1,000-row JSON array repeats its keys 1,000 times. Braces, quotes, field names, repeated strings: the API bills every one of them, on every request, at per-token prices.
Meaning lives in the values. Most of the bulk is repetition you can strip and put back exactly. That is the only part Tokendoo touches.
02 / How it works
Four transforms, in order.
Each step is structural and reversible. We keep it only when the payload gets smaller. If nothing helps, we emit the input unchanged and say so in the header.
Canonicalisation
Drop whitespace, sort keys, normalise numbers. Gives every later step a deterministic input.
{ "sku": "a-114", "qty": 2 }{"qty":2,"sku":"a-114"}Key dictionary, off by default
Repeated keys become base-36 ordinals plus a table. On the shipping corpus it missed the ≥10% token-gain bar, so it stays off until it earns a place.
{"quantity":2,"status":"active"}{"0":2,"1":"active"} k:["quantity","status"]Tabular collapse
An array of same-shape objects becomes one schema row plus value rows. Keys are written once, not once per record.
[{"qty":2,"sku":"a-114"},
{"qty":1,"sku":"a-115"}]["__T",["qty","sku"], [[2,"a-114"],[1,"a-115"]]]
Value interning
Strings that repeat across the payload move into a table and get referenced by ordinal. The table ships with the output, and every figure on this page includes it.
"eu-west-1" × 40
"0" × 40 v:["eu-west-1"]
The result is a T3 wire string, T388:…, plus a JSON dictionary. Both count in every ratio. Quoting savings without the dictionary would overstate them.
03 / Why subscribe
The codec is free. Model-specific profiles will be paid.
The engine, corpus and benchmark harness are published under Apache 2.0. The included cl100k, o200k and Llama reference tables remain free. The planned service will provide evaluated profiles for covered models.
Symbol choice changes token cost. Current tables are derived from the target tokenizer vocabulary: their symbols each cost one token in isolation. The actual cost must also include their spelling inside JSON, the dictionary and the reading legend.
| alphabet | median token ratio |
|---|---|
| control characters | 0.6575 |
| printable prefix | 0.5241 |
| bare base-36 | 0.4207 |
| derived from vocabulary | 0.3868 |
The cl100k and Llama tables share 438 symbols out of the 1,377 in the Llama table. Their cost must be measured with the target tokenizer. The model’s ability to read the representation requires a separate evaluation.
A profile will combine an alphabet, compression settings and comprehension results for a defined model and set of tasks. The planned subscription will provide access to covered profiles, versioning and regression tracking.
04 / Measurements
The numbers we ship against.
Exact cl100k_base counts on a synthetic, published corpus, benched 2026-08-07 with the shipped defaults: derived_cl100k_v1 alphabet, tabular collapse and value interning on, key dictionary off. Every after-count includes the dictionary.
| fixture | what it is | tokens in | tokens out | token ratio | byte ratio |
|---|---|---|---|---|---|
homogeneous_100 | 100 records, one schema | 2 903 | 1 229 | 0.4234 | 0.327 |
homogeneous_1000 | 1,000 records, one schema | 29 003 | 8 387 | 0.2892 | 0.246 |
realistic_api | mixed API response | 3 200 | 2 415 | 0.7547 | 0.689 |
size_10k | ≈10 KB mixed payload | 3 860 | 1 493 | 0.3868 | 0.304 |
size_100k | ≈100 KB mixed payload | 39 983 | 11 663 | 0.2917 | 0.246 |
size_250k | ≈250 KB mixed payload | 98 603 | 29 156 | 0.2957 | 0.247 |
prose_heavy | long text values, thin structure | 2 965 | 2 980 | 1.0051 | 1.002 |
shipping fixtures, median token ratio 0.3868. Corpus and bench code are in the repository; re-running the bench reproduces every count.
The last row is where the tool does nothing. Structural compression has nothing to grip on prose, and prose_heavy comes out 0.5% larger. We keep the row: it is the case where this does not help, and you should see it.
Round-trip is enforced in the open repository: property-based tests require decompress(compress(x)) to equal x on JSON values.
05 / Get the library
06 / How it plugs in
Compress locally. Call the model yourself.
The path that works
use tokendoo::compress;
use tokendoo::json::legend::legend_text_for_flags;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = r#"{"users":[{"id":1,"name":"a"},{"id":2,"name":"b"}]}"#;
let result = compress(input)?;
// Prompt pieces you send to your provider. Your key never leaves your process.
let legend = legend_text_for_flags(result.flags);
let dictionary = serde_json::to_string(&result.dictionary)?;
send_to_provider(&legend, &result.compressed, &dictionary);
Ok(())
}
fn send_to_provider(legend: &str, data: &str, dictionary: &str) {
// POST to your provider with Authorization: Bearer <YOUR_KEY>.
// Tokendoo is not on this path.
let _ = (legend, data, dictionary);
}What we never do
# We never sit in front of the model provider. # caller ──(your OpenAI/Anthropic key)──▶ tokendoo-proxy ──▶ model ✗ # caller ──▶ compress (local) ──▶ you ──(your key)──▶ model ✓ # We never receive your provider key. # We never see the model's response. # We never receive your payload.
Language not covered yet? The codec is published under Apache 2.0: about four hundred lines of deterministic code. Reimplement it. There will be no compression API to wait for.
07 / Zero retention
Nothing to leak, by design.
The codec processes JSON in your environment and does not send it to Tokendoo. You build the prompt and call your model provider with your own key.
The planned service will distribute downloadable profiles. Payloads will remain processed in your environment, independently of profile downloads.
This section describes payload processing. The waitlist has a separate purpose, stated in its form.
There is no paste box on this page, on purpose. A product built on not collecting payloads does not ask you to upload JSON to prove that it does not keep JSON.
08 / Status & roadmap
What ships, what we are measuring, what is planned.
as of 2026-10-14
Shipped
- tokendoo 0.1.0 on crates.io; API docs on docs.rs/tokendoo
- Lossless round-trip over JSON values, checked by 1,000+ property-test cases
- Local Rust library; compression never requires a network hop
- JSON mode only; inputs up to 256 KiB
To validate
- Per-model comprehension: the harness exists, but validated model coverage has not been established. The codec’s round trip does not prove answer quality.
- Symbol choice inside actual JSON and transform selection. Measurements must include the dictionary and legend, then be confirmed on an independent corpus.
Planned
- Local diagnosis: compare your JSON and available configurations, including the full cost of the representation.
- First evaluated profile: explicitly identified tokenizer, model, settings, task types and comprehension results.
- npm and PyPI publication from the same Rust core; bindings are present in the repository.
- Downloadable, versioned profiles with verified table identities and decoding compatibility.
- Subscription to profiles for covered models and a custom offer for your data shapes. Pricing follows validation.
09 / Free and paid
Free engine. Paid model profiles.
Paid offer planned. Profiles and pricing will be offered after validation.
The library runs locally with its free reference tables. The planned subscription will provide access to profiles for covered models, their evaluations and maintenance.
Free
Apache 2.0 codec with included cl100k, o200k and Llama reference tables. Usable offline; they remain free in the releases that distribute them.
One family
Profiles for covered models within one family: alphabet, compression settings, evaluation scope and updates.
Multiple families
Access to profiles across all families actually covered. Each model will have an explicit validation scope.
Custom
Profiles optimized and evaluated on your data shapes and tasks, with execution in your environment.
The subscription will pay for profile access and maintenance. It will not depend on local usage counters or estimated savings.
A profile will be described as validated only for models and tasks actually evaluated. Codec fidelity and answer quality are verified separately.
10 / Questions
The objections, before you raise them.
Seven questions a sceptical reader asks in the first two minutes. The answers are the ones we would give in a code review.
Why not just gzip the payload?
Doesn't prompt caching already solve this?
Does the model actually understand the compressed form?
Why paid profiles?
Apache 2.0. The planned service will provide evaluated configurations for covered models, maintenance and custom profiles. A new model version does not necessarily change its tokenizer; representation cost and comprehension must be tracked separately.Your fixtures are synthetic and you wrote them.
Zero retention. How would I know?
You are adding a network hop to save a few cents.
11 / npm and PyPI
Leave an email. We send one when the library reaches npm and PyPI.
The Rust crate is published. One email when npm and PyPI ship, nothing before, nothing after.