xron-format
v0.3.0
Published
Extensible Reduced Object Notation — lossless data serialization achieving ~80% token reduction for LLM contexts
Maintainers
Readme
xron-format
Lossless data serialisation achieving up to ~80% token reduction for LLM contexts.
Installation
npm install xron-formatQuick Start
import XRON from 'xron-format';
const data = [
{ id: 1, name: 'Alice', role: 'Engineer' },
{ id: 2, name: 'Bob', role: 'Designer' },
{ id: 3, name: 'Carol', role: 'Engineer' },
];
const compressed = XRON.stringify(data, { level: 'auto' });
const restored = XRON.parse(compressed);
// deep-equals the original dataCompression Levels
| Level | Typical Reduction | Best For | |-------|-------------------|----------| | 1 | ~60% | Human-readable output | | 2 | ~70% | Balanced compact format | | 3 | ~80% | Maximum token savings | | auto | Best available | Picks optimal level per dataset (Never-Worse Guarantee) |
9-Layer Pipeline
- Schema extraction — removes repeated property keys
- Positional streaming — eliminates key tokens in tabular data
- Dictionary encoding — deduplicates repeated string values
- Type-aware encoding — compresses booleans, nulls, dates, UUIDs
- Column templates — extracts common prefix/suffix patterns
- Substring dictionary — deduplicates repeated substrings
- Delta + repeat compression — compresses sequential numbers
- Separator reduction — minimises field separator overhead
- Tokeniser alignment — optimises BPE token boundaries
Guarantees
- Lossless:
XRON.parse(XRON.stringify(data))deep-equalsdata - Never-Worse: Auto mode compares all XRON levels against raw
JSON.stringifyand returns whichever is shortest — if XRON would be larger (e.g. tiny payloads), it falls back to JSON - Native BigInt support
- Zero dependencies (tiktoken is an optional peer for token counting)
Links
License
MIT
