toonkit2
Type-SafeCompactHuman-ReadableMIT

toonkit2

A parser & serializer for TOON — Typed Object Oriented Notation. Transform JSON to compact TOON format and back with built-in type awareness.

$ npm install toonkit2
Docs → Import & Functions
🔗

Import & Functions

ES Module Import
import { toon, toonToJson, jsonToToon, toonFetch } from "toonkit2";
console.log(toon.version()); // "2.5.1"
import { toon as expressToon } from "toonkit2/express";
// or: import { toon as fastifyToon } from "toonkit2/fastify"

Function Signatures

toonToJson(input: string)Parses TOON text and returns a JavaScript object with all types resolved.
jsonToToon(obj: any)Converts a JavaScript object/array into TOON format string.
safeParse(value: string)Parses JSON when valid and preserves the original string when it is not JSON.
toon.toToon(value)Serializes a runtime value or ordinary JavaScript value to canonical TOON.
toon.toJSON(value)Returns a plain cloned JavaScript value without runtime metadata.
toon.clone(value)Creates an independent clone that can be mutated safely.
toon.equals(a, b)Checks two values for structural equality.
toon.version()Returns the installed toonkit2 package version for runtime verification.