Lightweight Object Notation

JSON, with the keys written once.

LWON writes the shape of your data once and the values by position. It converts any JSON value and back without loss, and uses 21–42% fewer Claude tokens than minified JSON on typical API and tool data.

  • Any JSON value
  • Exact round trip
  • No dependencies

45 tokens

[
  {"id":1,"name":"Ada","role":"admin"},
  {"id":2,"name":"Linus","role":"dev"},
  {"id":3,"name":"Grace","role":"dev"}
]
id name role
[
[1 Ada admin]
[2 Linus dev]
[3 Grace dev]
]
The same three records. LWON names the fields once and lists the values by position, so it spends 51% fewer tokens (45 → 22, o200k tokenizer).
How it works

Five rules cover every JSON value.

The examples below are real encoder output.

Keys once, values by position

A header names the fields. Each row lists only values, in header order. Words without spaces need no quotes.

LWON
id name [tags]
[
[1 Ada [math code]]
[2 Linus []]
]

Nesting stays compact

Objects and lists of objects get their own field lists inside the header, so deep data is still written once.

LWON
{[orders[id customer[name city] [items[sku qty]]]]}
[[[A-1 [Ann Izmir] [[K1 2]]]]]

Trees refer to themselves

@ reuses an enclosing field list. Menus, file trees and comment threads need one short header at any depth.

LWON
title [children[@]]
[
[Docs [[Spec []] [API []]]]
]

Rare keys go by name

Keys most rows lack move to a * slot at the end of the header, and each row names them. Models read sparse data without counting positions.

LWON
id level userId *
[
[1 info 7]
[2 warn 9]
[3 error ~ {"retry":2}]
]

Anything else stays JSON

A value that does not fit the header is written as plain JSON in its slot. Nothing is ever dropped.

LWON
id [data[deep]]
[
[1 text]
[2 [1 [true]]]
]
Benchmarks

Fewer tokens on the data you actually send.

Six realistic datasets, counted with Claude's own tokenizer and measured against minified JSON, the fair baseline, and against TOON, another format built for LLMs. LWON's lead grows with nesting.

Claude tokens per dataset, relative to minified JSON
  • JSON (minified)
  • TOON
  • LWON

users Flat table, 100 rows

JSON (minified)
4,295
TOON
2,510 · −42%
LWON
2,503 · −42%

orders Nested objects and arrays, 50 orders

JSON (minified)
8,259
TOON
7,435 · −10%
LWON
4,808 · −42%

issues GitHub-style issues with nullable objects, 30 rows

JSON (minified)
4,378
TOON
4,414 · +1%
LWON
2,760 · −37%

menu Recursive tree, 3 levels

JSON (minified)
562
TOON
578 · +3%
LWON
362 · −36%

logs Log events with optional fields, 80 rows

JSON (minified)
4,393
TOON
4,472 · +2%
LWON
3,452 · −21%

search Search tool result: object with a result list

JSON (minified)
2,930
TOON
2,200 · −25%
LWON
2,298 · −22%

Counted with the Claude count_tokens API (Haiku, Sonnet and Opus 5.5 share a tokenizer). Data only. TOON: @toon-format/toon 4.4.0. Lower is better.

Method and full results →

Lossless

Every value comes back exactly.

Nulls, empty arrays, missing keys, odd key names and fields that change type from row to row all survive the trip. The reference library is tested against a shared conformance suite and a fuzzer that generates hostile JSON.

100,000fuzzed round trips, all exact
112conformance and unit tests
0runtime dependencies
How LWON writes empty and missing values
JSONLWONMeaning
nullnullThe key is there; its value is null.
[] / {}[] / {}Empty array, empty object.
key missing~The key is absent. At the end of a row it can be left out.
For AI

Convert before the model reads it.

Tool results, API responses and retrieved records are mostly repeated keys and punctuation. Encode them as LWON in your tool layer and send a primer of about 328 tokens once, so the model reads the same data for fewer tokens.

132 of 132 answers were correct when Claude Haiku, Sonnet and Opus 5.5 answered 44 questions about LWON data, the same score as with JSON.

Read the AI guide
  1. 1 · Your tool or APIJSON
  2. 2 · In your codelwon.encode(data)
  3. 3 · The promptPRIMER + LWON

See what LWON does to your data.

Paste any JSON. The playground converts both ways and counts the tokens in your browser.

Open the playground