Serialization Basics

Compare JSON, MessagePack, CBOR, Protocol Buffers, Avro, and raw binary for IoT payloads

animation
serialization
json
messagepack
protobuf
cbor
avro
binary
iot
interactive
Interactive serialization format comparator for IoT payloads, byte-size estimates, link airtime, format trade-offs, byte sketches, and mobile-safe reference material.
Animation Serialization IoT Payloads

Serialization Basics

Compare how the same IoT message changes when it is encoded as readable JSON, compact binary JSON, schema-based bytes, or a fixed raw packet. The animation shows byte cost, airtime, debugging value, and schema trade-offs together.

-- Recommended format
-- Bytes saved vs JSON
-- Selected link airtime

Serialization Comparator Workbench

Serialization means wire shape

The same message meaning can be carried as text, tagged binary values, numbered fields, or a fixed byte layout.

Field names cost bytes

JSON repeats keys such as temperature. Binary and schema formats avoid part of that overhead.

Schemas trade flexibility

Protobuf and Avro can be compact, but both sides must agree on field numbers, types, and evolution rules.

Small links amplify choices

A few dozen bytes may not matter on Wi-Fi, but they can dominate airtime and battery on LPWAN links.

1

Message meaning

Start with the fields and values.

2

Text encoding

JSON keeps names and punctuation.

3

Binary tags

MessagePack and CBOR shorten the shape.

4

Schema bytes

Protobuf and Avro replace names with schema rules.

5

Link cost

Convert bytes into airtime on a real link.

6

Decision

Pick the format that matches the constraint.

Message meaning Read the source message before comparing wire formats.

Message meaning

Read the source message before comparing wire formats.

Stage 1 of 6
Serialization comparator animation A source IoT message flows through several serialization formats, producing byte-size bars, link airtime, and a recommendation. Sensor telemetry message One meaning, several wire encodings.
What changed A payload has fields.

Serialization changes representation, not the sensor meaning.

Diagnosis JSON is readable

Readable keys help humans debug but add bytes to every message.

Result --

Use Step or Play to walk through the comparison.

Payload And Byte Sketch

The JSON sketch is literal UTF-8. Binary sketches are representative teaching sketches, not a substitute for measuring your exact library and schema.


          

        

Controls

Switch the message, link, and priority to see why the best format changes.

Message type
Optimization priority
Network link
Formats shown
Scale

Calculation Trace

These are teaching estimates designed to show direction and trade-off. For production, measure the exact encoder, schema, field values, and protocol framing you use.

payload_bytes = encoded_message_length JSON bytes = UTF-8 length of minified JSON JSON includes quotes, punctuation, and field names in every message.
airtime_ms = payload_bytes * 8 / link_bps * 1000 daily_MB = bytes * msgs_per_hour * devices * 24 / 1e6 Serialization cost is only payload cost; protocol headers are a separate layer.
best_format = max(priority_weighted_score) score uses size, debugging, ecosystem, schema, and fit There is no universal winner. The correct choice depends on the constraint.

Reference Material

Use these cards to check vocabulary, format behavior, and the limits of this simplified comparison.

Format Quick Reference
JSON Readable text with field names. Excellent for debugging and APIs, but usually the largest payload.
MessagePack Binary encoding for JSON-like data. Compact without requiring a separate schema file.
CBOR Concise binary object representation. Strong fit for CoAP and constrained standards-based IoT.
Protocol Buffers Schema-based numbered fields. Compact and fast when sender and receiver share the schema.
Avro Schema-oriented data format often used in pipelines and storage systems with schema evolution needs.
Raw binary Smallest fixed layout, but fragile. It needs exact agreement on byte order, scale, and versioning.
Selection Checklist
Need human debugging? Use JSON while building, logging, or configuring devices unless the link budget forbids it.
Need compact self-description? MessagePack or CBOR keep types with the payload while reducing text overhead.
Control both endpoints? Schema-based formats become more attractive when you control sender, receiver, and deployment cadence.
Expect long-lived data? Plan schema evolution before deploying millions of devices that may send old messages for years.
Operate on LPWAN? Measure bytes carefully. Payload limits, retries, and duty-cycle rules can dominate the design.
Need exact interop? Document version, endian order, integer scaling, optional fields, and unknown-field behavior.
Technical Accuracy Notes
Representative sizes The byte counts are realistic teaching estimates. Exact sizes vary by encoder, schema, value ranges, and options.
Headers excluded The comparison is payload-only. MQTT, CoAP, UDP, IP, TLS, and radio framing add their own bytes.
Avro nuance Avro may carry schema externally, in an object container, or through a registry. This page models message-level payload cost.
Raw binary caution Raw binary is not self-describing. It can be excellent for frozen telemetry and painful for evolving products.
Compression interaction Large JSON batches may compress well; tiny IoT packets often cannot afford compression setup overhead.
Security still matters Compact binary is not automatically safe. Validate lengths, types, schema version, and untrusted input.