json-parser/json-parser
FreeVery low footprint DOM-style JSON parser written in portable ANSI C
FreeFree tier
About json-parser/json-parser
json-parser is a very low footprint DOM-style JSON parser written in portable C89 (ANSI C). It is BSD-licensed with no dependencies, meaning you can simply drop json.c and json.h into your project. The parser never recurses or allocates more memory than necessary to represent the parsed JSON, making it highly efficient. It features a simple API with operator sugar for C++ and provides compile-time options like JSON_TRACK_SOURCE for error reporting and custom integer types. Runtime options include enabling C-style comments, custom allocators, and handling UTF-8 byte order marks. For serialization, a companion library called json-builder is available.
Key Features
Written in portable C89 (ANSI C)
BSD licensed with no dependencies
Never recurses during parsing
Allocates only necessary memory to represent JSON
Simple API with C++ operator sugar
Supports compile-time options: JSON_TRACK_SOURCE, custom json_int_t
Runtime options: comments, custom allocators, UTF-8 BOM handling
Companion json-builder for serialization
Pros & Cons
Pros
- Extremely low memory footprint
- No dependencies, easy to integrate
- Portable across platforms (ANSI C)
- BSD license allows commercial use
- Never recurses, avoids stack overflow
- Custom memory allocator support
Cons
- DOM-style parser only (no streaming/SAX-style)
- No built-in serialization (requires separate json-builder library)
- Limited error reporting unless JSON_TRACK_SOURCE is enabled
- Not thread-safe by default (shared state not documented)
Best For
Parsing JSON in resource-constrained or embedded systemsAdding JSON parsing to C/C++ projects without external dependenciesLightweight JSON processing where memory footprint is criticalC++ projects that benefit from operator sugar for JSON value access
FAQ
How do I install json-parser?
Simply copy json.c and json.h into your project. Optionally, a makefile is provided to build a static/dynamic library, but it is not required.
Is json-parser thread-safe?
The library itself does not use global state, but each json_value must not be accessed concurrently. Thread safety depends on how you manage the parsed data.
Can I use json-parser in commercial projects?
Yes, it is licensed under a BSD license, which permits commercial use.
Does json-parser support comments in JSON?
Comments are not enabled by default but can be enabled at runtime by setting the json_enable_comments flag in json_settings.