JSON vs CBOR on an ESP32
WICC 2026, peer-reviewed, with N. A. Balich, F. A. Balich and F. Steinmetz: JSON versus CBOR serialization on an ESP32 at 240 MHz.
Over 50 trials per format, CBOR payloads were 28.2% smaller, and parsing took about 12 µs instead of about 7.8 ms.
The problem
Embedded devices in industrial systems often exchange data as JSON because it is readable and every tool supports it. On a microcontroller that also runs a control loop, though, every millisecond spent parsing a message is a millisecond taken from control. We wanted to know how much JSON actually costs on real hardware, compared with CBOR, a binary format designed for constrained devices.
The setup
- Hardware: an ESP32 microcontroller at 240 MHz as the receiver
- Sender: a Python application
- Transport: MQTT over Wi-Fi
- Message: the same object-detection message, encoded once as JSON and once as CBOR
- Trials: 50 per format
- Measured on the ESP32: payload size, CPU cycles to deserialize (read directly from the chip), and parse time with a microsecond timer
What we measured
| Measure | JSON | CBOR |
|---|---|---|
| Average payload size | 709.8 bytes | 509.9 bytes |
| Average CPU cycles to deserialize | 1,875,667 | 3,015 |
| Average parse time | 7,815.5 µs | 12.5 µs |
The CBOR message was 28% smaller. Parsing it took about 12 µs instead of about 7.8 ms.

What it means
The message got about a quarter smaller, but parsing got hundreds of times cheaper. The bottleneck was not the network. It was the work of turning text back into data on a small processor.
That matters for control loops. At 100 Hz, each cycle has a 10 ms budget. JSON parsing alone used about 78% of it, leaving almost nothing for the control logic. CBOR used about 0.12%.
Parsing one JSON message takes about 7.8 ms, about 78% of the 10 ms cycle.
What I noticed
Across the 50 trials, JSON parse time was not steady. Most trials took about 8 ms, but several came in well under that, between about 5 and 7 ms. CBOR stayed flat at about 12 µs throughout. For a control system, that variation can matter as much as the average, because timing guarantees depend on the worst case.

What I’d do differently
Test several message shapes and sizes, not one object-detection message. Report the spread (minimum, maximum, p99), not only averages. Measure energy directly instead of inferring it from CPU time. Measure end-to-end latency, including the network, alongside parse time.draft