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.
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?
How are numbers encoded?
Which output formats are available?
Does UBJSON preserve key order?
Is the output standard UBJSON?
Is my JSON uploaded anywhere?
More JSON Tools
View AllCSON to JSON
Parse a CSON file into JSON in one click: indented blocks, block array...
Obfuscate JSON
Obfuscate a JSON structure instantly: rename keys to sequential or ran...
JSON to Bencode
Encode a JSON data structure into bencode: integers, byte strings with...
JSON to BSON Converter
Convert a JSON document into binary BSON encoding directly in your bro...
Unescape JSON String
Decode a JSON string literal back into readable plain text. Handles es...