Skip to main content

Helper to merge multiple configuration files into one file.

Project description

blendconf

A powerful CLI tool for merging and converting configuration files across different formats.

Features

  • 🔀 Merge multiple config files - Combine configurations from different sources
  • 🔄 Format conversion - Convert between JSON, YAML, TOML, and ENV formats
  • 📤 Flexible output - Write to file or print to stdout
  • 🎯 Simple CLI - Easy to use command-line interface

Supported Formats

  • JSON (.json)
  • YAML (.yaml, .yml)
  • TOML (.toml)
  • ENV (.env)

Installation

We recommend using uv for the best experience, alternative install methods are available here.:

# Install uv (if you haven't already)
curl -LsSf https://astral.sh/uv/install.sh | sh

Then, you can run blendconf directly without installation:

# Run blendconf directly with uvx (no installation needed!)
uvx blendconf --help

Usage

Merge Configuration Files

Merge multiple config files and save the result:

uvx blendconf config1.json config2.json -o merged.json

Merge configs and print to stdout:

uvx blendconf config1.toml config2.toml

The output format is determined by the first input file when printing to stdout, or by the output file extension when using -o.

Convert Between Formats

Convert a JSON file to TOML:

uvx blendconf config.json -o config.toml

Convert YAML to JSON:

uvx blendconf settings.yaml -o settings.json

Print converted file to stdout (uses input file format by default):

uvx blendconf config.json  # outputs as JSON

Merge Strategy

You can specify how configs should be merged using the --strategy or -s option:

uvx blendconf base.yaml overrides.yaml -o final.yaml --strategy replace

Available strategies:

  • replace (default): Later values replace earlier ones
  • append: Lists are concatenated, dictionaries are merged

Examples

Check out the examples directory for sample configuration files:

# Merge two JSON configs
uvx blendconf examples/config1.json examples/config2.json -o merged.json

# Convert JSON to TOML
uvx blendconf examples/config1.json -o config.toml

# Merge YAML and TOML (prints as YAML)
uvx blendconf examples/settings.yaml examples/overrides.toml

# Merge and convert to different format
uvx blendconf examples/settings.yaml examples/overrides.toml -o final.json

Example: Merging Configs

config1.json:

{
  "database": {
    "host": "localhost",
    "port": 5432
  },
  "logging": {
    "level": "INFO"
  }
}

config2.json:

{
  "database": {
    "host": "production.db.example.com",
    "username": "admin"
  },
  "api": {
    "timeout": 30
  }
}

Result:

$ uvx blendconf config1.json config2.json
{
    "database": {
        "host": "production.db.example.com",
        "port": 5432,
        "username": "admin"
    },
    "logging": {
        "level": "INFO"
    },
    "api": {
        "timeout": 30
    }
}

Library Usage

While blendconf is primarily designed as a CLI tool, you can also use it as a Python library:

from pathlib import Path
from blendconf import merge_configs, dump_file, MergeStrategy

# Merge configs
merged = merge_configs(
    [Path("config1.json"), Path("config2.json")],
    MergeStrategy.REPLACE
)

# Save result
dump_file(merged, Path("output.yaml"), "yaml")

Note: The library currently has dependencies on typer and rich (used by the CLI). If you want to use blendconf as a library-only package without these dependencies, PRs are welcome! 🙏

Development

# Clone the repository
git clone https://github.com/hwmrocker/blendconf.git
cd blendconf

# Install dependencies with uv
uv sync

# Run tests
uv run pytest

# Run the CLI locally
uv run blendconf --help

Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

Especially welcome: PRs to make the library usable without CLI dependencies!

License

See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blendconf-1.0.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blendconf-1.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file blendconf-1.0.1.tar.gz.

File metadata

  • Download URL: blendconf-1.0.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for blendconf-1.0.1.tar.gz
Algorithm Hash digest
SHA256 45f6d3797af92c1df808b74fe4987b51d46ccc01a8402c640a07ecbe1ff50263
MD5 a37396deb78f988825461f9bfe4b4b64
BLAKE2b-256 7096a86ed6b253628bc693a9c3a2da431739d50614129be94ed6d8e1b69ce616

See more details on using hashes here.

Provenance

The following attestation bundles were made for blendconf-1.0.1.tar.gz:

Publisher: python-publish.yml on hwmrocker/blendconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file blendconf-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: blendconf-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for blendconf-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ad007d516db78440b8c823ac1129521f381e53852618c678e3658fd13a3ca9f
MD5 fc0d965ee27333906a97c52f2d06060f
BLAKE2b-256 b5f2ac646ed7dfcba6e8d9bae3d803956c11c638ac08125da16356b4827d65d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for blendconf-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on hwmrocker/blendconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page