Blazingly small, memory-efficient JSON library for C++ ⚡
Modern C++ JSON library designed for extreme memory efficiency. Built with C++23, provides both C++ and C APIs.
- 💾 Memory Champion: Minimal runtime footprint with immutable value deduplication
- 📚 Read-Heavy Optimized: Load once, read many times (R ≫ W)
- 🌍 Unicode Ready: Full ICU integration
- 🔧 Dual APIs: Modern C++ API + clean C API with C99 compatibility
- 🧪 Battle Tested: Comprehensive test suite
Perfect when memory is your bottleneck! 🌟
- Read-heavy workloads with repeated immutable values (int, float, bool, null, string)
- Memory-critical environments (embedded, mobile, IoT, large json data)
- Frequent small appends to JSON structures
- When you prefer reference counting over RAII semantics (optional but beneficial)
📖 Full Documentation | 🚀 Getting Started
Test: 481 MB ClickHouse dataset from jsonbench.com
%%{init: {'theme':'base', 'themeVariables': {'xyChart': {'backgroundColor': 'transparent', 'plotColorPalette': '#27ae60, #16a085, #2980b9, #2471a3, #5d6d7e, #c0392b, #a93226, #922b21, #7b241c'}}}}%%
xychart-beta horizontal
title "Memory Usage (MB) - Lower is Better"
x-axis ["hakka_json ⭐", boost, golang, python3.13, nlohmann, cppstd, python3.10, jansson, "rust/serde"]
y-axis "Memory (MB)" 1200 --> 3500
bar [1490, 1575, 2258, 2321, 2473, 2770, 2808, 3009, 3326]
| Library | Memory (MB) | Relative | File Size Multiplier |
|---|---|---|---|
| hakka_json 🏆 | 1,490 | 1.00x | 3.1x |
| boost_json | 1,575 | 1.06x | 3.3x |
| golang | 2,258 | 1.52x | 4.7x |
| python3.13 | 2,321 | 1.56x | 4.8x |
| nlohmann/json | 2,473 | 1.66x | 5.1x |
| cppstd | 2,770 | 1.86x | 5.8x |
| python3.10 | 2,808 | 1.88x | 5.8x |
| jansson | 3,009 | 2.02x | 6.3x |
| rust/serde_json | 3,326 | 2.23x | 6.9x |
🎯 Key Results:
- 6% less memory than boost_json (2nd place)
- 33% less memory than golang (3rd place)
- 55% less memory than rust/serde_json (last place)
- Only 3.1x file size - competitors need 3.3x to 6.9x
📊 Full benchmark details: tests/benchmark/README.md
| Platform | Compiler | Versions | Status |
|---|---|---|---|
| Linux | GCC | 11, 12, 13, 14, 15, 16 | |
| Linux | Clang/LLVM | 17, 18, 19, 20, 21, 22 | |
| macOS | Apple Clang | Xcode 15.4, 16.2, 26.0 | |
| Windows | MSVC | VS 2022 |
Sanitizers Tested: Address, Undefined Behavior, Thread, Memory (Clang) | Build Types: Debug, Release
Contributions welcome! See CONTRIBUTING.md.
Dual-licensed: Boost Software License 1.0 OR BSD 3-Clause. See LICENSE.
Made with ❤️ by scc@cycraft