Library / SDK
rust-cli/config-rs avatar
rust-cli/config-rs

config-rs: seven file formats, a path syntax with two operators, and no way to write a value back

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).

3,228 stars263 forksRustApache-2.0

At a glance

What is it?
A layered configuration library for Rust that reads defaults, overrides and the environment, parses seven file formats behind individual feature flags, and looks up nested values with a two-operator subset of a JSON path syntax. It states in bold that it cannot write values back to a file, and its package include list names a build script the repository does not contain.
Who is it for?
This is the right choice when a program should read its configuration from several places and hand values out as ordinary Rust types, and the wrong choice for anything that has to persist a setting. Three things to check before you adopt it.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • rust-cli/config-rs3,228 ★ · +16
Star history
Repository2026-09-242026-11-23
rust-cli/config-rs3.2k3.2k

16 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The library says out loud that it will not write your values back

Two paragraphs into a README that is otherwise a list, there is a note in bold telling you what the library cannot do. It cannot be used to write changed configuration values back to the configuration files. That is a real constraint rather than a missing feature, and it decides the shape of anything built on top: a program that reads its configuration can adjust values at runtime, but persisting that adjustment needs a different mechanism, and a settings screen has to write the file itself. For a library whose whole job is to gather configuration from several places, refusing to own the write path is a defensible boundary, and it is worth knowing before you design around it rather than after.

Seven formats, each behind its own feature flag

The format list is longer than the Rust ecosystem's usual two or three, and it is the most distinctive thing about the library. It reads JSON, TOML, YAML, INI, RON, JSON5 and Corn. Each one is behind a cargo feature flag named after its format, so a project pays only for the parsers it enables, which is the right shape for a library that wants to be a default dependency. Four of those formats link to other people's repositories rather than to a specification: the Rust object notation crate, the JSON5 crate, the INI parser, and a YAML parser that has moved implementation. The seventh, Corn, links to a language site rather than to a library at all, and it is the entry in the list most likely to puzzle someone scanning the feature flags.

Nested lookups support two operators out of a whole path syntax

Values can be read through a formatted path, and the README is precise about how much of a JSON path syntax that means: a subset, currently supporting the child operator and the subscript operator. Two examples are given, one for a nested key and one for indexing into a list and reading a field of the element. So you can reach a port inside a server block or a name inside an array of databases, and you cannot filter, wildcard or slice your way to a value. Everything the expression language does not cover has to be done by reading a wider value and walking it in ordinary code, which is a reasonable trade and one that keeps the path parser small enough to trust.

Loosely typed means the conversion decides, not the file

One of the six bullets in the feature list is about typing and it is worth reading carefully. Configuration values may be read in any supported type, as long as a reasonable conversion exists. So the file format does not decide a value's type; the type you ask for does, and the library finds a conversion. That is what makes an environment variable or an INI string usable as a number or a boolean without a schema, and it is also why a typo in a value tends to surface as a conversion failure at the moment you read it rather than as a parse error with a line number. The bullet list also gives the layering itself: set defaults, set explicit values to override them programmatically, and read from the environment, which is the shape a twelve-factor application needs and the reason the README links that methodology.

The metadata records one licence and the repository declares two

The licence section of the README offers a choice, Apache 2.0 or MIT, at the option of the user, and the repository carries a file for each. The package manifest agrees, declaring the workspace licence as the pair. The packaging metadata outside the repository does not: it records Apache 2.0 alone. For a library that exists to be depended on by other projects, that gap matters more than it would elsewhere, because automated licence checks read the metadata field and will report one licence where the project actually offers two. Anyone auditing a dependency tree should read the repository rather than the index entry.

The package include list names a build script the tree does not have

The workspace manifest restricts what goes into the published crate, and the list has eight entries: a build script, the source directory, the manifest itself, the lock file, the licence files, the readme and the examples. The first of those is the interesting one. There is no build script in the repository's top level. So the include list claims a file that the checkout does not contain, which means either the file exists somewhere the listing does not reach or the entry is a leftover from an earlier layout. Either way it is a small packaging bug worth reporting, because a published crate whose file list references something absent is the kind of thing that only shows up when someone builds from the tarball.

Edition 2024, an MSRV of 1.88, and a lint table with holes in it

The workspace declares the 2024 edition and a minimum supported compiler version of 1.88, and uses the third edition of the workspace resolver. The lint configuration is the interesting part, because it is a table rather than a file: nine compiler lints set to warn, one of which is about unnameable types leaking out of public interfaces, and then a long list of clippy rules where some are set to warn, some are explicitly allowed, and several are commented out. Three of the disabled ones are the numeric cast checks, and the table carries inline comments explaining the exceptions it does keep, such as preferring an explicit array in one case and naming a return value in another. So the linting is deliberate, and its gaps are marked.

Three release files at the root and an example set named after concepts

The top level has the files you would expect and three you might not. One configures the release process and one configures which commits are committed directly to the repository, and one is the dependency audit configuration, so the release path is a file rather than a convention in someone's notes. There is also a configuration for a spell checker, a commit message linter, a pre-commit configuration and a policy file about the use of AI in contributions. The examples directory is organised the way the library's concepts are: one for source priority, one for reading from a string rather than a file, one for an asynchronous source, one for a static environment, one for watching a file, one for a custom format, and a settings file to read.

Editorial conclusion

This is the right choice when a program should read its configuration from several places and hand values out as ordinary Rust types, and the wrong choice for anything that has to persist a setting. Three things to check before you adopt it. It cannot write, so a settings screen needs another mechanism entirely. Its type handling is conversion-based rather than strict, which is convenient and means a malformed value surfaces as a conversion failure rather than as a parse error with a line number. And its nested lookup supports only the child and subscript operators, so a query that would need a filter or a wildcard has to be written in code.

Frequently asked questions

What is the config crate for Rust used for?

It is a layered configuration system for Rust applications with strong support for twelve-factor setups. It sets defaults, accepts explicit values to override them, reads seven file formats and the environment, and lets you read nested values through a formatted path.

Which file formats does config-rs read?

JSON, TOML, YAML, INI, RON, JSON5 and Corn, each enabled behind its own cargo feature flag. Values can also come from the environment, and a custom format can be plugged in through a trait.

Can config-rs write configuration back to a file?

No. The README states in bold that the library cannot be used to write changed configuration values back to the configuration files, so anything that persists a setting needs another mechanism.

Can I add a file format that config-rs does not support?

Yes, through an extensibility point described as a format trait. Implementing it lets a custom, less popular or proprietary format integrate with the library's existing APIs, and the repository carries an example directory for it.

What license is config-rs under?

Either of two, at the user's option: Apache 2.0 or MIT, with a file for each in the repository and the manifest declaring the pair. The packaging metadata outside the repository records only Apache 2.0.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. Project website
  4. README
  5. rust-cli/config-rs on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rust-cli-config-rs.svg)](https://hysenlabs.com/projects/rust-cli-config-rs)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/rust-cli-config-rs.svg)](https://hysenlabs.com/projects/rust-cli-config-rs)

Was this useful?