toon-rs

Library Listed Dormant

Token-Oriented Object Notation – a token-efficient JSON alternative for LLM prompts

Checked · Sources

Downloads
8,018
Dependents
5
Stars
22
Forks
1
Contributors
0
Commits
7
Latest release
0.1.2 ·

About

From the project README ·

TOON (Token-Oriented Object Notation) - Rust

A Rust implementation of Token-Oriented Object Notation (TOON), a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage.

This is a Rust port of the original JavaScript/TypeScript implementation: @byjohann/toon.

Why TOON?

LLM tokens cost money, and standard JSON is verbose. TOON conveys the same information with 30-60% fewer tokens than JSON:

JSON (257 tokens):

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

TOON (166 tokens):

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

Installation

Add this to your Cargo.toml:

[dependencies]
toon = "0.1.0"
serde_json = "1.0"

Quick Start

use toon::encode;
use serde_json::json;

fn main() {
    let data = json!({
        "user": {
            "id": 123,
            "name": "Ada",
            "tags": ["reading", "gaming"],
            "active": true
        }
    });

    let toon_output = encode(&data, None);
    println!("{}", toon_output);
}

Output:

user:
  active: true
  id: 123
  name: Ada
  tags[2]: reading,gaming
Read the full README

Features

  • 💸 Token-efficient: 30–60% fewer tokens than JSON
  • 🍱 Minimal syntax: removes redundant punctuation
  • 📐 Indentation-based structure: like YAML
  • 🧺 Tabular arrays: declare keys once, stream rows
  • 🦀 Type-safe: built with Rust's strong type system

Examples

Objects
use toon::encode;
use serde_json::json;

let data = json!({
    "id": 123,
    "name": "Ada",
    "active": true
});

println!("{}", encode(&data, None));

Output:

active: true
id: 123
name: Ada
Arrays of Objects (Tabular Format)
let data = json!({
    "items": [
        { "sku": "A1", "qty": 2, "price": 9.99 },
        { "sku": "B2", "qty": 1, "price": 14.5 }
    ]
});

println!("{}", encode(&data, None));

Output:

items[2]{price,qty,sku}:
  9.99,2,A1
  14.5,1,B2
Custom Delimiters

Use tab or pipe delimiters for even more token savings:

use toon::{encode, EncodeOptions, Delimiter};

let data = json!({
    "tags": ["reading", "gaming", "coding"]
});

let mut options = EncodeOptions::default();
options.delimiter = Delimiter::Tab;

println!("{}", encode(&data, Some(options)));

Output:

tags[3	]: reading	gaming	coding
Length Markers

Add a # prefix to array lengths for clarity:

let mut options = EncodeOptions::default();
options.length_marker = Some('#');

let data = json!({"tags": ["a", "b", "c"]});
println!("{}", encode(&data, Some(options)));

Output:

tags[#3]: a,b,c

API

encode(value: &serde_json::Value, options: Option<EncodeOptions>) -> String

Converts a serde_json::Value to TOON format.

Parameters:

  • value: A reference to a serde_json::Value to encode
  • options: Optional encoding options (defaults to standard TOON format)

Returns: A String containing the TOON-formatted output

EncodeOptions
pub struct EncodeOptions {
    pub indent: usize,                  // Spaces per indentation level (default: 2)
    pub delimiter: Delimiter,            // Delimiter for arrays (default: Comma)
    pub length_marker: Option<char>,     // Optional length prefix (default: None)
}
Delimiter
pub enum Delimiter {
    Comma,  // ,
    Tab,    // \t
    Pipe,   // |
}

Format Overview

  • Objects: key: value with 2-space indentation for nesting
  • Primitive arrays: Inline with count, e.g., tags[3]: a,b,c
  • Arrays of objects: Tabular format with header, e.g., items[2]{id,name}:
  • Mixed arrays: List format with - prefix
  • Quoting: Only when necessary (special chars, structural ambiguity)

Python Bindings

Python bindings are available in the pybinding/ directory.

Installation
pip install toon-pyrs

Or build from source:

cd pybinding
pip install maturin
maturin build --release
pip install target/wheels/*.whl
Python Usage
import json
import toon

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

result = toon.encode(json.dumps(data))
print(result)

Output:

users[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user
Publishing Python Package
cd pybinding
maturin build --release
pip install twine
twine upload target/wheels/*

License

MIT License © 2025

See Also

Original JS/TS implementation: @byjohann/toon

Runs on
GPU support unknown
What shows it
  • no dependency or feature matches a backend row
Native code
None found
  • No native code found
Python bindings
No Python binding crate found
License
MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

toon-rs beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
toon-rs This page Listed Dormant

Token-Oriented Object Notation – a token-efficient JSON alternative for LLM prompts

8,018 downloads over 30 days 5 22 0.1.2 GPU support unknown No native code found MIT
pdf_oxide Featured

The fastest Rust PDF library — 0.8ms mean, 5× faster than the industry leaders, 100% pass rate on 3,830 real-world PDFs. Text extraction, Markdown/HTML conversion, PDF creation and editing.

Python bindings

316,729 downloads over 30 days 30 1,180 0.3.78 GPU support unknown Binds native code: aws-lc-rs (feature fips), lcms2-sys (feature icc-lcms2), ort-sys (feature gpu) Apache-2.0 OR MIT
toon-rust Featured

Token-Oriented Object Notation (TOON) - a token-efficient JSON alternative for LLM prompts

160,383 downloads over 30 days 67 190 0.7.0 GPU support unknown No native code found MIT
oxidizePdf App Listed

Pure Rust PDF library for AI/RAG: structure-aware chunking, no ML, no C deps.

62,285 downloads over 30 days Not applicable 194 5.5.7 GPU support unknown No native code found MIT
serde_toon Listed

A Serde-compatible TOON (Token-Oriented Object Notation) serialization library

2,384 downloads over 30 days 4 13 0.3.0 GPU support unknown No native code found Apache-2.0 OR MIT
blazr App Listed

Inference server for LLMs, speech and embeddings: OpenAI-compatible routes with streaming, plus speech synthesis (TTS) and transcription (ASR). Serves Llama, Mistral, Qwen, Mamba2, MLA+MoE and hybrid models from SafeTensors, AWQ, GPTQ and GGUF.

8 binary downloads per release Not applicable 7 0.7.1 CUDA, WebGPU Binds native code: ring (feature distributed) Apache-2.0
chunkr App Listed

Vision infrastructure to turn complex documents into LLM-ready data

0 binary downloads per release Not applicable 4,157 Not measured Not measured AGPL-3.0
Why ListedNo archive, New or Featured rule places it, so it is Listed.

What it lacks for Featured

  • It has 3 active dependents and 3 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 22 stars, 1 fork and 0 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
  • The project is dormant and not finished. Dormancy rule

What else the check found

  • The last activity is on 30 Oct 2025, 375 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
  • The oldest outside issue waits 357 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule

Not measured: Latest release fails cargo check.

Exact rules: Listed, Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.1.2 base 300, capped at 3 releases = 150, raised to the 365-day floor: E = 365 days
  • dormancy: last activity 2025-10-30, 375 days ago, E = 365: dormant
  • rot: oldest unanswered issue 357 days (limit 270), no maintainer reply in 365 days
  • featured: not featured: active_users 3 < 11 and new_adopters 3 < 9 and repository route stars 22 (needs 4539), forks 1 (needs 434), contributors 0 (needs 79); dormant and not stable
  • listed: listed: no archive, new or featured rule applies

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption3 active dependents, 3 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents3crates.io database dumpYes
New dependents (365 days)3crates.io database dumpYes
Peak active dependents3crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 12 months ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2025-10-30GitHub repositoryYes
Latest release2025-10-29crates.io database dumpYes
First release2025-10-29crates.io database dumpYes
Latest version0.1.2crates.io database dumpYes
Days the oldest outside issue waits for a reply357GitHub repositoryYes
Maintainer replies over 365 days0GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution3 releases, 8,018 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases3crates.io database dumpYes
Downloads over 30 days8018crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository22 stars, 1 forks, 0 contributors, 7 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars22GitHub repositoryYes — one part of the repository route
GitHub forks1GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account0GitHub contributorsYes — one part of the repository route
Commits on the default branch7GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseMITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesNo native code foundcrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly5crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.