diaryx.org / projects /

fig

Zig MIT / Apache-2.0

Lossless parsing and editing of config files — down to every comment, key order, and blank line.

Editing config files programmatically shouldn't mean reformatting them. fig parses JSON, JSON5, YAML, TOML, ZON, and its own dialect into a lossless AST, then splices your change in: a one-line diff, everything else byte-for-byte identical.

  • Set a value, keep the file. fig set config.yaml service.replicas 5 touches one line.
  • Comments are data. Attach one inline: fig comment --inline config.yaml service.replicas "bumped" — and they survive every edit and conversion.
  • Convert without loss. YAML → JSON5 → TOML carries comments along.
  • Edit embedded config too. Frontmatter inside Markdown is just another document to fig.

Where it fits

fig is the metadata layer of Diaryx — frontmatter in every entry goes through it, and flower is a structural editor built on its tree. Standalone, it's a library (crates.io, npm) and a CLI for anyone who scripts against config files.

Status

Actively maintained and published: the Rust crate wraps the Zig core, an npm package ships it for JavaScript, and Homebrew carries the CLI.