ArduinoJson
📟 JSON library for Arduino and embedded C++. Simple and efficient.
ArduinoJson is a lightweight C++ JSON library for microcontrollers like Arduino, ESP32, and Teensy, it reads and writes JSON (and MessagePack) while fitting into the tiny memory constraints of embedded hardware.
ArduinoJson is a JSON library written in C++ for microcontrollers and embedded systems. Microcontrollers, such as those found in Arduino boards, ESP32 chips, and Teensy boards, have very limited memory compared to regular computers, so a JSON library that runs well on them needs to be especially careful about size and memory use. ArduinoJson is designed to meet those constraints while still being straightforward to use.
The library handles both reading (deserialization) and writing (serialization) of JSON. You can parse a JSON string to extract values from it, or build a JSON document from variables in your code and convert it to text. It also supports MessagePack, a binary data format that is more compact than JSON and often used in embedded applications where bandwidth or storage matters.
Because microcontrollers come in such a wide variety, ArduinoJson has been tested on many different boards: standard Arduino boards (Uno, Mega, Nano), ESP8266 and ESP32 chips common in Wi-Fi projects, Teensy boards, Particle boards, and Texas Instruments MSP430, among others. It is also usable in any standard C++ project, not just Arduino, and works with most embedded development environments including PlatformIO, Keil, IAR, and the Arduino IDE.
The library is header-only, which means you add it to your project by including a single file rather than building a separate compiled library. It has no external dependencies, which matters on platforms where pulling in additional code is complicated. Unit test coverage is close to 100%, and the library is continuously tested against multiple compiler versions and fuzzed by Google's OSS Fuzz infrastructure to catch parsing edge cases.
Documentation includes tutorials, worked examples, a troubleshooter, an FAQ section, and a paid book for those who want a more thorough guide.
Where it fits
- Parse JSON responses from a REST API on an ESP32 Wi-Fi project.
- Serialize sensor readings into a JSON string and send them to a server from an Arduino board.
- Use MessagePack instead of JSON to reduce payload size on a bandwidth-limited embedded connection.
- Store configuration settings as a JSON file on an SD card and load them at startup.