NOW LET US – AI RAG SaaS Studio TP.HCM
NOW LET US
Digital Product Studio
Back to news
DEV-TOOLS...3 min read

RX – a new random-access JSON alternative

Share
NOW LET US Article – RX – a new random-access JSON alternative

RX (REXC) is a high-performance JSON alternative that offers 18x smaller payloads and 23,000x faster lookups by enabling direct access to encoded bytes without full deserialization.

REXC encoder, decoder, and data tool. Drop-in replacements for JSON.stringify and JSON.parse that produce smaller output, skip deserialization on read, and create near-zero heap allocations.

JSON forces a tradeoff: parse everything up front (slow, memory-heavy) or don't cache at all. REXC eliminates the tradeoff:

18x smaller— binary-encoded numbers, de-duplicated strings, shared schemas, prefix-compressed paths.23,000x faster single-key lookup— O(log n) binary search on sorted indexes, directly on the encoded bytes. No parse step.Near-zero heap pressure— the parsed result is a Proxy over a flat byte buffer. The GC doesn't trace its contents.

Benchmarked on a real production dataset: a 35,000-key website deployment manifest.

npm install @creationix/rx # library
npm install -g @creationix/rx # CLI (global)
npx @creationix/rx data.rx # CLI (one-off)
import { stringify } from "@creationix/rx";
const payload = stringify({ users: ["alice", "bob"], version: 3 });
// Returns a string — store it anywhere you'd store JSON
import { parse } from "@creationix/rx";
const data = parse(payload) as any;
data.users[0] // "alice"
data.version // 3
Object.keys(data) // ["users", "version"]
JSON.stringify(data) // works — full JS interop

The returned value supports property access, Object.keys(), Object.entries(), for...of, for...in, Array.isArray(), .map(), .filter(), .find(), .reduce(), spread, destructuring, and JSON.stringify(). Existing code that consumes the parsed result doesn't need to change.

rx data.rx # pretty-print as tree
rx data.rx -j # convert to JSON
rx data.json -r # convert to REXC
cat data.rx | rx # read from stdin (auto-detect)
rx data.rx -s key 0 sub # select a sub-value
rx data.rx -o out.json # write to file

See CLI Reference below for full options.

Tip: Add a shell function for quick paged, colorized viewing that works on both .json and .rx files. To install paste this into your shell profile.

p() { rx "$1" -t -c | less -RFX; }
# p data.rx — pretty-print with color, auto-pages large output

There is also a web-based viewer in development for inspecting REXC documents with expandable tree navigation, syntax-highlighted node types, and tabs for raw REXC, JSON, and ref dictionaries.

For performance-critical paths or when working with Uint8Array buffers directly:

import { encode, decode, open } from "@creationix/rx";
// encode returns Uint8Array (no string conversion)
const buf = encode({ path: "/api/users", status: 200 });
// decode/open take Uint8Array, return Proxy-wrapped value
const data = open(buf) as any;
data.path // "/api/users"
data.status // 200
import { stringify, encode } from "@creationix/rx";
// Add sorted indexes to containers with >= 10 entries (enables O(log n) key lookup)
stringify(data, { indexes: 10 });
// Always index, even small containers
stringify(data, { indexes: 0 });
// Disable indexes entirely
stringify(data, { indexes: false });
// External refs — shared dictionary of known values
const refs = { R: ["/api/users", "/api/teams"] };
stringify(data, { refs });
// Streaming — receive chunks as they're produced
stringify(data, { 
onChunk: (chunk, offset) => process.stdout.write(chunk),
});

Both stringify and encode accept the same options. stringify returns a string; encode returns a Uint8Array.

If the encoder used external refs, pass the same dictionary to the decoder:

const refs = { R: ["/api/users", "/api/teams"] };
const data = parse(payload, { refs });

Ref values are returned as-is — they can be strings, numbers, objects, arrays, or even functions and symbols.

The Proxy returned by parse/decode/open is read-only and behaves like a frozen JS object:

const obj = parse(payload) as any;
obj.newKey = 1; // throws TypeError("rexc data is read-only")
delete obj.key; // throws TypeError("rexc data is read-only")
"key" in obj; // works (uses zero-alloc key search)

Containers are memoized — repeated access to the same property returns the same Proxy instance:

obj.nested === obj.nested // true

© 2026 Now Let Us. All rights reserved.

Source: Hacker News

Advertisement
Ad slot ready: 5887729102

More in this category

EXPLORE TOPICS

Discover All Categories

Deep dive into the specific technology sectors that matter most to you.