On this page
Overview
JSON for Modern C++ is a single-header library that treats JSON much like native C++ objects and arrays. Its STL-like API covers parsing strings and streams, updating values, formatted output, and conversion to binary formats.
Features and best fit
Hands-on tested within the scope below · Content checked:
Key features
Work with JSON through container-like C++ operations
Objects and arrays can be assembled with initializer lists and accessed with operator[], at, find, and related APIs. parse reads strings or streams, while dump and stream output serialize values, so configuration files and API payloads can share one value model.
Sources: [1]
Best fit
Add JSON handling to an existing C++ application
It fits teams that want configuration, messages, and test fixtures inside C++ without another process or large runtime. Developers familiar with STL containers can use familiar conversion and iteration patterns.
Sources: [1]
Before adoption
Account for performance goals and malformed input
The README explicitly prioritizes developer convenience rather than minimum memory use or maximum speed. Applications accepting untrusted data still need exception handling, input-size limits, and an explicit policy for non-UTF-8 strings during serialization.
Sources: [1]
3.12.0 / C++ compiler with C++11 support
Pinned release header compiled; parsing, mutation, serialization, reparsing, and assertions executed locally.
Official sources
- [1]JSON for Modern C++ 3.12.0 README(2026-10-04)
- [2]JSON for Modern C++ 3.12.0 release(2026-10-04)
- [3]JSON for Modern C++ 3.12.0 MIT license(2026-10-04)
Supplemental curator note
Its readable API and low-friction integration cover tasks from configuration loading to API response generation. For workloads dominated by speed or memory constraints, benchmark it against alternative JSON implementations with representative data.
Try it in 3 steps
- 1
Download the 3.12.0 single header
With curl and a C++11 compiler available, save json.hpp from the published release in a working directory.
mkdir -p json-3.12.0-demo && cd json-3.12.0-demo && curl -fL -o json.hpp https://github.com/nlohmann/json/releases/download/v3.12.0/json.hpp - 2
Write a parsing and serialization example
Generate a small C++ program that parses JSON, adds a value, serializes it, and parses it again.
printf '%s\n' '#include "json.hpp"' '#include <cassert>' '#include <iostream>' 'int main() {' ' auto value = nlohmann::json::parse(R"({"project":"OSS Tanbou","stars":3})");' ' value["ready"] = true;' ' const auto encoded = value.dump();' ' const auto decoded = nlohmann::json::parse(encoded);' ' assert(decoded["project"] == "OSS Tanbou" && decoded["ready"] == true);' ' std::cout << encoded << "\n";' '}' > demo.cpp - 3
Compile and verify the round trip
Build in C++11 mode, check the decoded values with assertions, and print the serialized result.
c++ -std=c++11 -I. demo.cpp -o demo && ./demo
Growth
Growth trends · Last 30 days
50,720 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 178
- Open PRs
- 52
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- json
- json-pointer
- json-patch
- cbor
- msgpack
- header-only
- stl-containers
- json-serialization
- json-parser
- rfc-6901
- rfc-6902
- rfc-7159
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Windows Package Manager CLI26,479 Stars
1 shared tag(s) · 1 shared category(s) · Same language
search, install, and update Windows packages through a CLI, PowerShell, and COM API
C++ - {fmt}25,864 Stars
1 shared tag(s) · 1 shared category(s) · Same language
handle C++ and C string formatting, output, dates, and ranges with type-safe format strings and portable performance
C++ - Catch221,506 Stars
1 shared tag(s) · 1 shared category(s) · Same language
write C++ unit tests, BDD scenarios, and micro-benchmarks in one test framework and integrate them with CMake and CTest
C++ - Filament20,561 Stars
1 shared tag(s) · 1 shared category(s) · Same language
render real-time physically based 3D graphics across Android, iOS, desktop, and the web
C++ - bgfx17,536 Stars
1 shared tag(s) · 1 shared category(s) · Same language
abstract Direct3D, Metal, OpenGL, Vulkan, WebGL, and other backends into a cross-platform rendering layer for existing engines and frameworks
C++ - Arduino-ESP3217,465 Stars
1 shared tag(s) · 1 shared category(s) · Same language
develop for the ESP32 SoC family with the official Arduino core, libraries, board definitions, and integrated Espressif toolchains
C++
Report incorrect information
Tell us if any listing information is incorrect or outdated.