Skip to content
BetterPass logo

CBOR Encode/Decode Online

Convert JSON to CBOR and back, read RFC 8949 diagnostic notation, render semantic tags, and diff the raw bytes side by side — all in your browser.

Binary output
Result

What is CBOR Encode/Decode Online?

CBOR (Concise Binary Object Representation, RFC 8949) is the compact binary serialization format behind WebAuthn passkeys, COSE messages, and IoT protocols like CoAP. It encodes the same structures as JSON into a fraction of the bytes while adding native support for byte strings, semantic tags, and bignums. This toolbox turns CBOR into something you can actually inspect: it converts JSON to CBOR (hex or base64), decodes binary back into readable JSON or RFC 8949 diagnostic notation, renders common semantic tags readably, and diffs the JSON vs CBOR byte streams side by side.

Convert — encode JSON to CBOR (hex or base64) or decode it back, with file upload in both directions.
Diagnostic notation — view decoded CBOR as RFC 8949 §8 diagnostic notation: h'...' byte strings, <<...>> embedded data, and 1(...) tags.
Common tag rendering — tag 0/1 dates, tag 2/3 bignums, tag 24 embedded CBOR, tag 32 URIs, tag 36 MIME.
Hex Dump Diff — compare the JSON text bytes against the CBOR bytes byte-for-byte with offset rulers.
100% client-side — everything runs locally with cbor-x, the same codec used in the snippets.

Zero-Server Tool Data Guarantee

All encoding and decoding happens locally in your browser. Your data is never sent to any server.

How to Use

01

Choose Your Mode

Select 'Encode' to turn JSON data into CBOR binary, or 'Decode' to convert CBOR bytes back to readable output. Drop a file instead of pasting — decode mode reads the raw bytes.

02

Set Encoding Type

Pick either 'Hex' or 'Base64' as the text representation for your binary CBOR data.

03

Pick an Output View (decode)

Choose 'JSON' for a plain decoded object or 'Diagnostic' for RFC 8949 §8 diagnostic notation with h'...' byte strings, <<...>> embedded data, and n(...) tags.

04

Inspect Semantic Tags

Dates (tag 0/1), bignums (tag 2/3), and embedded CBOR (tag 24) render readably in both views, so nothing is silently dropped.

05

Diff the Bytes

Open the Hex Dump Diff tab to see JSON and its CBOR encoding side by side with offset rulers and top-level type annotations.

Common Use Cases

WebAuthn / FIDO2 Debugging

Decode CBOR-encoded authenticator data from WebAuthn registration and authentication ceremonies.

IoT Data Serialization

Encode sensor readings and device state into compact CBOR for transmission over constrained networks.

COSE Message Inspection

Decode the payload of COSE-signed or encrypted messages used in firmware update and device authentication protocols.

Round-Trip Testing

Verify encode → decode round-trips, read diagnostic notation, and inspect tag-encoded values during schema migrations.

Implementation Examples

JavaScriptJavaScript (cbor-x)
import { encode, decode } from 'cbor-x';
const toHex = (bytes) => [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
// Round-trip test: JSON -> CBOR bytes -> JSON
const doc = { id: 42, name: "sensor-7", active: true };
const bytes = encode(doc);
console.log(toHex(bytes)); // b90003626964182a646e616d656873656e736f722d3766616374697665f5
const decoded = decode(bytes);
console.log(decoded); // { id: 42, name: 'sensor-7', active: true }
console.log(JSON.stringify(decoded) === JSON.stringify(doc)); // true
// Big integers keep full precision through the tag-2 bignum
const huge = decode(encode(18446744073709551616n));
console.log(typeof huge, huge); // bigint 18446744073709551616

CBOR vs JSON vs MessagePack

FeatureCBORJSONMessagePack
RFCRFC 8949RFC 8259No formal RFC
Self-describingYes (type + value)No (text only)Partially
Semantic tagsYes (tag system)NoExtension types
SizeVery compactVerboseCompact
Schema required?NoNoNo
Primary useIoT, WebAuthn, CoAPAPIs, configHigh-perf APIs
ImplementationModerateTrivialSimple

Production Best Practices & Security

Use CBOR for constrained devices — its compactness makes it ideal for IoT, sensors, and low-bandwidth networks. Why:CBOR uses variable-length integer encoding and minimal type prefixes, producing significantly smaller payloads than JSON. This saves precious bandwidth and energy on battery-powered or low-bandwidth IoT devices.
Understand the type system — CBOR maps JSON types differently (e.g., integers vs floats); be aware of automatic type selection. Why:CBOR distinguishes between positive integers, negative integers, and floating-point values at the binary level. A JSON number like 42 may be encoded as an integer, while 42.0 becomes a float, causing unexpected behavior if your decoder assumes JSON-like type rules.
Use semantic tags — leverage CBOR's tag system to add meaning to data (e.g., tag 1 for epoch dates, tag 24 for embedded CBOR). Why:Without semantic tags, a CBOR parser has no way to know that a string is a date or that bytes represent a cryptographic key. Tags add self-describing metadata that enables correct interpretation across different systems and implementations.
Validate input carefully — malformed CBOR can cause parser errors; always validate before processing. Why:Maliciously crafted CBOR can contain deeply nested structures or extremely large lengths that cause stack overflows or excessive memory allocation. Input validation prevents denial-of-service attacks against your parser.
Use hex for debugging — CBOR's binary format is hard to read raw; hex representation helps with analysis. Why:Raw CBOR bytes are not human-readable. Hex encoding preserves the exact byte sequence while making type codes, lengths, and values visible for manual inspection and debugging.
Consider COSE for security — if you need to sign or encrypt CBOR data, use the COSE standard built on top of CBOR. Why:COSE (RFC 9052) defines standardized ways to sign, encrypt, and authenticate CBOR data. Rolling your own CBOR security scheme risks subtle implementation vulnerabilities that COSE has already addressed through extensive peer review.

Frequently Asked Questions

CBOR (Concise Binary Object Representation) is a binary serialization format defined in RFC 8949 and inspired by JSON, designed to pack data into the smallest possible footprint. Think of it as JSON's compact, binary sibling — it represents the same kind of key-value structures and arrays, but encodes them using a fraction of the bytes.

CBOR is the format behind WebAuthn (passkey authentication), COSE (CBOR Object Signing and Encryption), and many IoT protocols where every byte counts on constrained devices.