Estafette
Compose Login
You are browsing eu.zone1 in read-only mode. Log in to participate.
rss-bridge 2025-11-25T09:12:21+00:00

Stop Wasting LLM Tokens. ๐Ÿ›‘

If you're using JSON for your LLMs, you are likely overpaying for your API usage.

---

Tech

Stop Wasting LLM Tokens. ๐Ÿ›‘

If you're using JSON for your LLMs, you are likely overpaying for your API usage.

[Image: Apal Shah]

Apal Shah

25 Nov 2025
โ€ข 1 min read

[Image: Stop Wasting LLM Tokens. ๐Ÿ›‘]

If you're using JSON for your LLMs, you are likely overpaying for your API usage.

Iโ€™ve always treated JSON as the default for data transfer. But while working on optimizing LLM workflows recently, I learned that it can be incredibly expensive. ou are paying for every curly brace { }, quote ", comma , and repeated key.

#### Recently, I came across TOON (Token-Oriented Object Notation).

The difference in token density is shocking when you see it side-by-side.

โŒ Standard JSON:

`
{ "id": 1, "role": "admin", "status": "active", "plan": "enterprise" },
{ "id": 2, "role": "editor", "status": "active", "plan": "pro" },
{ "id": 3, "role": "viewer", "status": "inactive", "plan": "free" },
{ "id": 4, "role": "viewer", "status": "active", "plan": "pro" },
{ "id": 5, "role": "editor", "status": "inactive", "plan": "enterprise" }
`

โœ… TOON:

`
users[5]{id, role, status, plan}
1, admin, active, enterprise
2, editor, active, pro
3, viewer, inactive, free
5, editor, inactive, enterprise
`

Now, do the math on scale.

In the JSON example above, Iโ€™m sending the keys "id", "role", "status", and "plan" five separate times.

> Imagine doing this for 10,000 or 100,000 records.

I believe in the LLMs or RAG pipelines, where context windows and API costs matter, this optimization could be necessary for many applications.

---

#### Btw, you don't have to do this manually. There are libraries for this.

Check this out: https://toonformat.dev/
GitHub: https://github.com/toon-format/toon

Or you can see the benchmarks here: https://toonformat.dev/guide/benchmarks.html

#### Let's look at the example in Typescript:

Installation:

`
npm install @toon-format/toon
`

Example:

`
import { encode } from '@toon-format/toon'

const data = {
users: [
{ id: 1, name: 'Alice', role: 'admin' },
{ id: 2, name: 'Bob', role: 'user' }

console.log(encode(data))
`

Output:

`
users[2]{id,name,role}:
1,Alice,admin
2,Bob,user
`

---

You can explore this library and let me know in the comments if you saved tokens.

---

[Original source](https://gosink.in/stop-wasting-llm-tokens/)

Reply