Konfigo is a powerful command-line tool designed to streamline your configuration workflow. It excels at reading various configuration file formats (JSON, YAML, TOML, .env), merging them intelligently, and processing the combined data against a user-defined schema for validation, transformation, variable substitution, and even batch output generation.
Whether you're managing simple settings or complex, multi-layered configurations with environment-specific overrides, Konfigo provides the tools to do so efficiently and reliably.
- Multi-Format Support: Reads and writes JSON, YAML, TOML, and .env files.
- Flexible Merging: Intelligently merges multiple configuration sources, respecting order and immutability rules.
- Powerful Schema Processing:
- Variable Substitution: Inject dynamic values from environment variables (
KONFIGO_VAR_...), dedicated variable files (-V), or schema defaults. - Data Generation: Create new configuration values (e.g.,
concat,timestamp,random,id). - Data Transformation: Modify keys and values (e.g.,
renameKey,changeCase,addKeyPrefix,addKeySuffix,deleteKey,trim,replaceKey,setValue). - Data Validation: Enforce rules (
required,type,min,max,minLength,enum,regex). - Input/Output Schemas: Validate incoming data and filter outgoing data against defined structures.
- Variable Substitution: Inject dynamic values from environment variables (
- Batch Processing: Use the
konfigo_forEachdirective in a variables file to generate multiple tailored configuration outputs from a single schema and run. - Environment Variable Integration:
- Override any configuration value directly using
KONFIGO_KEY_path.to.key=value.
- Override any configuration value directly using
- Comprehensive CLI: Rich set of command-line options for fine-grained control over input, output, and processing behavior.
The primary way to install Konfigo is downloading a pre-built binary from the release page:
For other installation methods, please refer to the Installation Guide in our documentation.
Merge two configuration files (config.json and overrides.yml) and output the result to final.yml:
konfigo -s config.json,overrides.yml -of final.ymlMerge config.json, process it with schema.yml, use variables from staging-vars.yml, and output to staging_config.json:
konfigo -s config.json -S schema.yml -V staging-vars.yml -of staging_config.jsonHere are minimal examples for each of Konfigo's key features.
Convert config.json to config.yml.
config.json
{
"key": "value"
}Command
konfigo -s config.json -of config.ymlconfig.yml (Output)
key: valueMerge two JSON files, where keys in the second file override the first.
config1.json
{
"a": 1,
"b": 2
}config2.json
{
"b": 3,
"c": 4
}Command
konfigo -s config1.json,config2.jsonOutput (JSON)
{
"a": 1,
"b": 3,
"c": 4
}Substitute a variable from a file into the configuration.
config.json
{
"greeting": "Hello, ${user.name}"
}vars.yml
user:
name: WorldCommand
konfigo -s config.json -V vars.ymlOutput (JSON)
{
"greeting": "Hello, World"
}Generate a new value using a schema.
schema.yml
konfigo_schema:
properties:
request_id:
konfigo_generate:
type: id
id_type: uuidCommand
konfigo -S schema.ymlOutput (JSON)
{
"request_id": "...some generated uuid..."
}Rename a key using a schema.
config.json
{
"old_key": "value"
}schema.yml
konfigo_schema:
properties:
old_key:
konfigo_transform:
- type: renameKey
new_key: new_keyCommand
konfigo -s config.json -S schema.ymlOutput (JSON)
{
"new_key": "value"
}Validate that a required key is present.
config.json
{
"other_key": "value"
}schema.yml
konfigo_schema:
properties:
required_key:
konfigo_validate:
- type: requiredCommand
konfigo -s config.json -S schema.ymlOutput
Error: Validation failed: required_key is required
Generate multiple output files from a list of variables.
vars.yml
konfigo_forEach:
- user: alice
- user: bobschema.yml
konfigo_schema:
properties:
username:
konfigo_set:
value: ${user}Command
konfigo -S schema.yml -V vars.yml -of output/${user}.jsonOutput
output/alice.jsonwith{"username": "alice"}output/bob.jsonwith{"username": "bob"}
Override a configuration value from an environment variable.
config.json
{
"database": {
"host": "localhost"
}
}Command
export KONFIGO_KEY_database.host=prod.db.server
konfigo -s config.jsonOutput (JSON)
{
"database": {
"host": "prod.db.server"
}
}Below is a summary of the available command-line options. For more details, run konfigo -h.
Input & Sources
| Flag(s) | Description |
|---|---|
-s <paths> |
Comma-separated list of source files/directories. Use '-' for stdin. |
-r |
Recursively search for configuration files in subdirectories. |
-sj |
Force input to be parsed as JSON (required for stdin). |
-sy |
Force input to be parsed as YAML (required for stdin). |
-st |
Force input to be parsed as TOML (required for stdin). |
-se |
Force input to be parsed as ENV (required for stdin). |
-si |
Force input to be parsed as INI (required for stdin). |
Schema & Variables
| Flag(s) | Description |
|---|---|
-S, --schema <path> |
Path to a schema file for processing the config. |
-V, --vars-file <path> |
Path to a file providing high-priority variables. |
Output & Formatting
| Flag(s) | Description |
|---|---|
-of <path> |
Write output to file. Extension determines format, or use with -oX flags. |
-oj |
Output in JSON format. |
-oy |
Output in YAML format. |
-ot |
Output in TOML format. |
-oe |
Output in ENV format. |
-oi |
Output in INI format. |
Behavior & Logging
| Flag(s) | Description |
|---|---|
-c |
Use case-sensitive key matching (default is case-insensitive). |
-v |
Enable informational (INFO) logging. Overrides default quiet behavior. |
-d |
Enable debug (DEBUG and INFO) logging. Overrides -v and default quiet behavior. |
-h |
Show this help message. |
For detailed information on all features, CLI options, and schema capabilities, please visit our full documentation site:
Alternatively, you can browse the Markdown files directly in the /docs_markdown directory.
Key sections:
Contributions are welcome!
Konfigo is licensed under the MIT License.
