A JavaScript library for converting data to and from the TRON (Token Reduced Object Notation) format.
See full specification for the TRON format at: https://tron-format.github.io/
npm i @tron-format/tronimport { TRON } from '@tron-format/tron';
const value = [{ a: 1, b: 2 }, { a: 3, b: 4 }];
const tron = TRON.stringify(value);
console.log(tron);
// Output:
// class A: a,b
//
// [A(1,2), A(3,4)]
const parsed = TRON.parse(tron);
console.log(parsed);
// Output:
// [{ a: 1, b: 2 }, { a: 3, b: 4 }]In JavaScript, calling JSON.stringify(undefined) returns undefined. However, calling TRON.stringify(undefined) returns 'null' instead. This is intentional to better align with the function's return type (string only) for TypeScript.
Other cases of stringifying undefined are handled the same way as JSON.stringify. For example:
TRON.stringify([undefined])returns'[null]'(same behavior asJSON.stringify([undefined]))TRON.stringify({ a: undefined })returns'{}'(same behavior asJSON.stringify({ a: undefined }))
Want to try out TRON with your own JSON data?
Go to https://tron-format.github.io/#/playground and select "Custom Data".
Paste in your data to see TRON's token efficiency compared to other data formats!
MIT License © 2025-PRESENT Tim Huang