benhoyt/inih
FreeSimple .INI file parser in C, good for embedded systems
About benhoyt/inih
inih (INI Not Invented Here) is a simple .INI file parser written in C, designed to be small and simple for embedded systems. It consists of only a couple of pages of code and is compatible with Python's ConfigParser style of .INI files, including RFC 822-style multi-line syntax and name: value entries. The parser uses a callback-based (SAX style) approach, calling a handler function for each name=value pair. It supports parsing from files, strings, custom streams, or using a fgets-style reader. A wide range of compile-time options allow developers to control syntax features (multi-line, UTF-8 BOM, inline comments), parsing behavior (stop on first error, line numbers, callback on new sections), and memory allocation (stack vs heap, maximum line length). inih is distributed as open source under a permissive license.
Key Features
Pros & Cons
- Extremely small and lightweight, suitable for embedded targets
- Highly configurable via preprocessor defines without runtime overhead
- Permissive license (BSD-style) allows use in proprietary projects
- Well-tested with a history of use in other open source projects (e.g., uhub)
- Easy to integrate – just copy ini.c and ini.h into your project
- Supports multiple input sources (file, string, stream)
- Read-only parser: does not generate or modify INI files
- Callback-based API may be less intuitive than a DOM-style approach
- Configuration via preprocessor defines can be inconvenient for some project setups
- Only supports INI format, not JSON, YAML, or other structured config formats