Skip to content

TOON

A compact, human-readable way to write JSON data for LLM prompts, with a TypeScript SDK and CLI.

Stars
25.6k
Forks
1.1k
Licence
MIT
Language
TypeScript
Last update
5 days ago
Type
Library

What it is

TOON (Token-Oriented Object Notation) is a text format that represents JSON data in fewer characters, so it takes up fewer tokens when you paste it into a large language model prompt. It is meant to stay readable by humans. The project provides a TypeScript SDK, a command-line tool, and benchmarks comparing it with JSON.

  • Convert a JSON dataset to TOON before including it in an LLM prompt
  • Use the CLI to transform JSON files into the TOON format
  • Run the included benchmarks to compare token counts against JSON
  • Call the TypeScript SDK from a Node.js app to encode and decode TOON data

Great for

  • Developers who send structured JSON data to LLM prompts and want to reduce token usage
  • Teams using TypeScript who want an SDK to encode and decode the format
  • People who want to measure token savings with the included benchmarks
  • Anyone converting JSON files to TOON from the command line

Not ideal for

  • Projects that only exchange data between services and do not use LLMs, since the format's main benefit is for prompts
  • Users who need a format with broad support across many languages, since the README describes a TypeScript SDK and the other language support is unclear from the provided text
Step-by-step guide: how to use TOONInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install the package

    npm install @toon-format/toon
  2. 2

    Run it

    • Install the package with npm
    • Import the encode and decode functions from the SDK in your TypeScript or JavaScript code
    • Encode a JSON object to TOON and inspect the output
    • Compare the token count with the original JSON
  3. 3

    Get the most out of it

    • Run the included benchmarks to see token savings on your own type of data
    • Use the CLI to convert files without writing code
    • Check the project homepage at toonformat.dev for documentation beyond the README

Downloads

Strengths

  • Aims to reduce token count for JSON data sent to language models
  • Stays human-readable, so people can inspect the data directly
  • Ships with an SDK, a CLI, and benchmarks in one repository under the MIT license

Trade-offs

  • The benefit depends on the data and the model's tokenizer; savings are not guaranteed for every dataset
  • Adopting a new format means your prompts and tooling must handle TOON rather than standard JSON
  • The README was truncated, so details on the full specification and language support are not confirmed here

How it compares

ProjectStarsTypeLevelUpdatedBest for
toon (this)25.6kLibrarybeginner5 days agoDevelopers who send structured JSON data to LLM prompts and want to reduce token usage
json50.8kLibrarybeginner4 days agoC++ developers who need to read or write JSON in an application
store.js14kLibrarybeginner2.8 years agoFront-end developers who need to keep small pieces of data in the browser across page loads
go13.9kLibrarybeginner2.4 years agoGo developers who parse or produce large amounts of JSON and want to test a faster option

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.