lloyd/yajl logo

lloyd/yajl

Free

A fast streaming JSON parsing library in C.

FreeFree tier
Type
Open Source

About lloyd/yajl

YAJL (Yet Another JSON Library) is a fast, streaming JSON parsing library written in ANSI C. It is designed to be portable, robust (crash-proof), and minimal in memory footprint. Unlike many JSON libraries that impose a fixed in-memory data representation, YAJL is data representation independent, using callbacks to let users define how to handle parsed tokens. This enables incremental/stream parsing of JSON from a data stream without holding the entire text in memory. YAJL also generates verbose, context-rich error messages. It is released under the permissive ISC license, allowing use in both open source and commercial projects. The library has been tuned for performance while keeping the API clean and simple.

Key Features

Written in portable ANSI C
Streaming parsing (incremental, no need for full JSON in memory)
Data representation independent via callbacks (BYODR)
Minimal memory copying – returns pointers into client-provided text when possible
Generates verbose, context-rich error messages
Robust – designed to be crash-proof
Small footprint (tiny library)
P erformant – tuned for speed

Pros & Cons

Pros
  • Portable (ANSI C) and easy to build on multiple platforms
  • Very fast with minimal memory overhead
  • Streaming support enables processing large JSON without holding it all in memory
  • Callback architecture allows flexible data handling
  • Comes with a permissive ISC license (free for commercial and open source use)
  • Generates useful error messages to help debug malformed JSON
Cons
  • No built-in in-memory representation – requires user to implement callbacks (more work for simple use cases)
  • Only handles JSON parsing; does not include JSON generation
  • May trade off some performance optimizations for interface simplicity (as noted by author)
  • Relatively old library (latest stable release from 2007); may lack newer JSON features or security updates

Best For

Streaming JSON parsing from network sockets or filesJSON filtering and conversion (e.g., JSON to XML)Building custom in-memory JSON representationsBackend for higher-level JSON librariesPretty-printing JSON (included example filter program)

FAQ

Why was YAJL created?
The author found that existing C JSON parsing libraries did not meet requirements such as being written in C, portable, robust (crash-proof), data representation independent, fast, generating verbose error messages, supporting streaming incremental parsing, simple to use, and tiny. YAJL was created to satisfy these needs.
Is YAJL free to use?
Yes, YAJL is released under the permissive ISC license, which allows use in open source and commercial products without any fees.
Does YAJL support streaming JSON parsing?
Yes, YAJL can parse JSON data off a stream incrementally. This means you do not need to hold the entire JSON text in memory at once.
How does YAJL handle data representation?
YAJL is data representation independent. It uses callbacks to remain agnostic of the in-memory representation, so users must bring their own code to define and populate structures (BYODR).