JSON to UBJSON encodes a JSON document as Universal Binary JSON — the compact binary format that reads like JSON but costs a fraction of the bytes. Integers shrink to their smallest fitting size, strings are length-prefixed UTF-8, and objects and arrays are typed containers.
JSON to UBJSON
Encode a JSON document as Universal Binary JSON — the compact, typed binary format with the same structure as JSON.
Everything runs locally in your browser — your JSON never leaves this page.
JSON to UBJSON type mapping
| JSON value | UBJSON marker | Size |
|---|---|---|
| 42 (fits int8) | i | 1 byte |
| 255 (fits uint8) | U | 1 byte |
| 1000 (fits int16) | I | 2 bytes |
| 50000 (fits int32) | l | 4 bytes |
| any larger integer | L | 8 bytes |
| 3.14 | D | 8 bytes |
| "text" | S | 4 + len |
| true / false / null | T / F / N | 1 byte |
| { ... } / [ ... ] | { / [ | + children |
About JSON to UBJSON
Features
- Automatic integer optimization: int8 / uint8 / int16 / int32 / int64 as needed.
- float64 for all floating point values.
- Typed containers: objects and arrays written in optimized form.
- Three outputs: hex, base64 and a downloadable .ubj file.
- Byte counts so you can see exactly what you saved.
- Private: All encoding happens in your browser.
How to Use
- Paste your JSON into the input box (or load the sample).
- Encode and review the hex output.
- Compare byte counts between the JSON text and the UBJSON binary.
- Download the .ubj file if you need the real binary artifact.
Examples
Example 1 — Game networking. A developer encodes player state as UBJSON to cut payload size for a real-time multiplayer server.
Example 2 — IoT telemetry. An embedded engineer converts JSON sensor readings to UBJSON for a low-bandwidth uplink.
Example 3 — Caching. A backend team stores frequently-served JSON documents as UBJSON in Redis to save memory.
Example 4 — Protocol design. An architect prototypes a binary API by encoding sample JSON documents to compare sizes and structure.
Benefits
- Smaller payloads: UBJSON is dramatically smaller than JSON text.
- No schema needed: Like JSON, it is self-describing.
- Widely supported: Parser libraries exist for every major language.
- Instant: Encoding happens in the browser in milliseconds.
- Zero upload: Data never leaves your machine.
Frequently Asked Questions
What is UBJSON?
Universal Binary JSON is a compact binary format that keeps JSON's simplicity — objects, arrays, strings, numbers, booleans and null — while using single-byte markers and tightly packed integers. It is especially popular for game networking and IoT where every byte counts.
How are numbers encoded?
Intelligently: values that fit in 8, 16, 32 or 64 bits use the matching integer marker (i, U, I, l or L), and floating point values use float64 (D). The optimizer picks the smallest integer size automatically.
Which output formats are available?
Hexadecimal text, base64 text, and a downloadable .ubj binary file — all byte-for-byte identical encodings of the same document.
Does UBJSON preserve key order?
Yes. Objects are written as an ordered sequence of name-value pairs, so the output mirrors your JSON exactly.
Is the output standard UBJSON?
Yes. The encoder uses the standard string marker S with a 32-bit length and standard object and array containers with type and count optimization. Any UBJSON parser will read it.
Is my JSON uploaded anywhere?
No. Encoding happens entirely in your browser. Nothing is uploaded, stored or logged.