TOON for TypeScript is the official @toon-format/toon npm package: encode() turns any JSON-serializable value into TOON (Token-Oriented Object Notation) and decode() turns TOON back into the same JSON value. It is written in TypeScript and ships its own type definitions, so it works the same in TS and plain JavaScript. Use it to send LLMs your data with about 43% fewer tokens than JSON (42.6% in the official TOON v4.1 benchmark).
Usage Example
Quick start guide for encoding and decoding TOON format in TypeScript / JavaScript
import { encode, decode } from '@toon-format/toon';
// Your JSON data
const data = { "name": "Alice", "age": 30 };
// Convert to TOON format
const toonString = encode(data);
console.log(toonString);
// Output:
// name: Alice
// age: 30
// Convert back to JSON
const jsonData = decode(toonString);