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.
AnimationSerializationIoT 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.
Protocol BuffersRecommended format
54 B (61%)Bytes saved vs JSON
0.27 msSelected link airtime
TryChoose Telemetry on LoRa, select CBOR and JSON, then Step from Encode to Airtime.
ObserveFor 1 Telemetry payload, Bytes saved vs JSON and Selected link airtime show CBOR below JSON while the inspection view explains the debuggability trade-off.
ExplainAcross 1 report, CBOR replaces repeated textual syntax with compact typed tokens, reducing transmitted bytes but requiring a decoder to inspect the same fields.
Technical boundariesByte counts come from representative encodings rather than full libraries; framing, encryption, compression, schema negotiation, CPU energy, malformed inputs, and implementation-specific canonical forms are excluded.
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 meaningRead the source message before comparing wire formats.
Message meaning
Read the source message before comparing wire formats.
Stage 1 of 6
What changedA payload has fields.
Serialization changes representation, not the sensor meaning.
DiagnosisJSON 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_lengthJSON bytes = UTF-8 length of minified JSONJSON includes quotes, punctuation, and field names in every message.airtime_ms = payload_bytes * 8 / link_bps * 1000daily_MB = bytes * msgs_per_hour * devices * 24 / 1e6Serialization cost is only payload cost; protocol headers are a separate layer.best_format = max(priority_weighted_score)score uses size, debugging, ecosystem, schema, and fitThere 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
JSONReadable text with field names. Excellent for debugging and APIs, but usually the largest payload.MessagePackBinary encoding for JSON-like data. Compact without requiring a separate schema file.CBORConcise binary object representation. Strong fit for CoAP and constrained standards-based IoT.Protocol BuffersSchema-based numbered fields. Compact and fast when sender and receiver share the schema.AvroSchema-oriented data format often used in pipelines and storage systems with schema evolution needs.Raw binarySmallest 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 sizesThe byte counts are realistic teaching estimates. Exact sizes vary by encoder, schema, value ranges, and options.Headers excludedThe comparison is payload-only. MQTT, CoAP, UDP, IP, TLS, and radio framing add their own bytes.Avro nuanceAvro may carry schema externally, in an object container, or through a registry. This page models message-level payload cost.Raw binary cautionRaw binary is not self-describing. It can be excellent for frozen telemetry and painful for evolving products.Compression interactionLarge JSON batches may compress well; tiny IoT packets often cannot afford compression setup overhead.Security still mattersCompact binary is not automatically safe. Validate lengths, types, schema version, and untrusted input.
Related Animations
Continue from basic byte comparison into scenario costs, advanced trade-offs, and payload budgeting.