https://github.com/omkar-foss/zebra
A simple, fast, all-in-one config loader for Zig.
https://github.com/omkar-foss/zebra
config-loader zig zig-library zig-package ziglang
Last synced: about 2 months ago
JSON representation
A simple, fast, all-in-one config loader for Zig.
- Host: GitHub
- URL: https://github.com/omkar-foss/zebra
- Owner: omkar-foss
- License: mit
- Created: 2026-02-20T07:00:36.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-03-25T12:04:16.000Z (2 months ago)
- Last Synced: 2026-03-26T13:05:11.303Z (2 months ago)
- Topics: config-loader, zig, zig-library, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 282 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

# Zebra 
A simple, fast, all-in-one config loader for Zig. Supports reading dotenv, toml,
yaml and os env. Fully-functional and tested on Zig 0.15.2.
🏔️ Codeberg Mirror: https://codeberg.org/omkar-foss/zebra
## Design
- Inspired by the wonderful [viper (golang)](https://github.com/spf13/viper). Stripes instead of
fangs! 🦓
- Built to adhere to [Zen of Zig](https://ziglang.org/documentation/0.15.2/#Zen).
- Reads multiple config files and write into a single, unified hashmap or struct.
- Zero external dependencies, all loaders are native to zebra's code.
- Extensive tests to ensure zebra is as compliant as possible with file format standards.
## Usage
### Step 1. Install Zebra
- Fetch Zebra as a dependency to your Zig project:
```bash
zig fetch --save "git+https://github.com/omkar-foss/zebra#main"
```
- In your project's `build.zig`, add Zebra as a module dependency by placing below code before `b.installArtifact(exe);`:
```zig
const zebra = b.dependency("zebra", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zebra", zebra.module("zebra"));
```
### Step 2. Load yaml file as a map and print a key in it
To try out below example, copy the file [`env_test.yaml`](env_test.yaml) to your project folder, and then update your `src/main.zig` as follows:
```zig
const std = @import("std");
const zebra = @import("zebra");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var cfg: std.StringHashMap([]u8) = try zebra.core.loadAsMap(allocator, &[_][]const u8{"env_test.yaml"});
defer zebra.cleanup.deinitMap(allocator, &cfg);
std.debug.print("Output: {s}\n", .{cfg.get("person.name.first").?});
}
```
And then run `zig build run`, you'll get the below output:
```bash
$ zig build run
Output: John
```
Refer to [integration.zig](./tests/integration.zig) for detailed usage examples.
## Contributing
I'd really appreciate any help from the community towards making Zebra better. Please check out [CONTRIBUTING.md](CONTRIBUTING.md) to get started!
### Note on AI usage
Automated PRs without clear human oversight will be closed. I welcome the use of AI as a
productivity tool, but all PRs must be authored, reviewed, and justified by a human who takes full
responsibility for the logic, security, and maintenance of the code.