#config #configuration #conf #serde #type-safe


Type-safe, layered, light-weight, serde-based configuration library

4 releases

0.1.3 Apr 7, 2022
0.1.2 Mar 30, 2022
0.1.1 Nov 3, 2021
0.1.0 Jul 28, 2021

#39 in Configuration

Download history 7/week @ 2022-04-20 26/week @ 2022-04-27 34/week @ 2022-05-04 67/week @ 2022-05-11 22/week @ 2022-05-18 17/week @ 2022-05-25 32/week @ 2022-06-01 23/week @ 2022-06-08 10/week @ 2022-06-15 3/week @ 2022-06-22 10/week @ 2022-06-29 10/week @ 2022-07-06 26/week @ 2022-07-13 28/week @ 2022-07-20 32/week @ 2022-07-27 14/week @ 2022-08-03

102 downloads per month


919 lines

Confique: type-safe, layered configuration library

CI status of main Crates.io Version docs.rs

Confique is a rather light-weight library that helps with configuration management in a type-safe and DRY (don't repeat yourself) fashion.


  • Type safe: the code using the config values does not need to parse strings or unwrap any Options. All values already have the correct type.
  • Layered configuration: you can load from and then merge multiple sources of configuration.
  • Load config values from:
    • Environment variables
    • Files: TOML & YAML
    • Anything with a serde Deserializer (built-in support for more formats coming soon)
  • Based on serde: less code in confique (more light-weight) and access to a huge ecosystem of high quality parsers.
  • Easily generate configuration "templates" to describe all available config values to your users.

Simple example

use std::path::PathBuf;
use confique::Config;

struct Conf {
    #[config(env = "EXAMPLE_APP_USERNAME")]
    username: String,

    #[config(env = "EXAMPLE_APP_BUFFER_SIZE", default = 4096)]
    buffer_size: u32,

    log: LogConf,

struct LogConf {
    #[config(default = true)]
    stdout: bool,

    file: Option<PathBuf>,

let config = Conf::builder()

See the documentation for more information.

Comparison with other libraries/solutions

Obviously, all other libraries are more mature than confique.


  • Loosely typed:
    • You access configuration values via string path (e.g. "http.port") and deserialize at "use site".
    • No defined schema
  • More features
  • Larger library
  • If you need a "config template", you need to repeat code/docs


  • Also based on serde and also uses your own structs as data store, thus type safe
  • Instead of using partial types, aggregates different layers in a dynamic data store
  • If you need a "config template", you need to repeat code/docs

Just serde?

Serde is not a configuration, but a deserialization library. But you can get surprisingly far with just serde and it might actually be sufficient for your project. However, once you want to load from multiple sources, you either have make all your fields Option or repeat code/docs. With confique you also get some other handy helpers.

Status of this project

Confique is still a very young project. There are lots of features and improvements already planned. I'm developing this library alongside a web project that uses it.


Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~39K SLoC