A command-line interface for comparing configuration files with support for multiple formats.
npm install -g simple-config-diffOr use directly with npx:
npx simple-config-diff config1.json config2.jsonconfigdiff <left-file> <right-file>-f, --format <format>- Force specific format (json, yaml, xml, ini, toml, env, properties)-o, --output <format>- Output format (json, csv, table, summary) [default: table]-w, --watch- Watch files for changes and recompare--output-file <file>- Write output to file instead of stdout--force- Force comparison even if file formats differ--no-color- Disable colored output--ignore-case- Ignore case when comparing values--ignore-whitespace- Ignore whitespace differences
configdiff config1.json config2.jsonconfigdiff app.yml prod.yml -o jsonconfigdiff .env.local .env.prod -o summaryconfigdiff package.json package-lock.json -o json --output-file diff.jsonconfigdiff terraform.tf terraform.prod.tf --watchconfigdiff config.yaml config.json --force- JSON (
.json) - YAML (
.yaml,.yml) - XML (
.xml) - INI (
.ini) - TOML (
.toml) - Environment Variables (
.env) - HCL/Terraform (
.hcl,.tf) - Properties (
.properties) - CSV (
.csv) - Config (
.config,.conf)
Human-readable table format with colored output:
Path | Type | Old Value | New Value
database.host | changed | localhost | prod-db
database.port | added | | 5432
debug.enabled | removed | true |
Structured JSON format for programmatic use:
[
{
"path": "database.host",
"type": "changed",
"oldValue": "localhost",
"newValue": "prod-db"
}
]Comma-separated values for spreadsheet import:
Path,Type,Old Value,New Value
database.host,changed,localhost,prod-db
database.port,added,,5432
debug.enabled,removed,true,High-level overview of changes:
Configuration Diff Summary
==============================
Added: 1
Removed: 1
Changed: 1
Total: 3
The CLI tool can watch files for changes and automatically recompare them:
configdiff config.dev.json config.prod.json --watchThis is useful for:
- Development workflows
- CI/CD pipelines
- Real-time monitoring of configuration changes
0- Files are identical1- Files have differences or an error occurred
This makes it suitable for use in scripts and CI/CD pipelines:
if configdiff config.json config.prod.json; then
echo "Configurations are identical"
else
echo "Configurations differ"
fi# GitHub Actions example
- name: Compare configurations
run: |
configdiff config/staging.json config/production.json -o summary
if [ $? -eq 1 ]; then
echo "::warning::Configuration differences detected"
fi#!/bin/bash
# .git/hooks/pre-commit
configdiff config.json config.example.json --force#!/bin/bash
# compare-configs.sh
echo "Comparing development vs production configs..."
configdiff .env.development .env.production -o table --no-colorThe CLI tool provides clear error messages for common issues:
- File not found:
Error: Left file 'config.json' does not exist - Format mismatch:
Warning: File formats differ (json vs yaml). Use --force to compare anyway. - Parse errors:
Error: Failed to parse json file: Unexpected token - Invalid options:
Error: Invalid output format 'xml'. Valid formats: json, csv, table, summary
# Ignore case differences
configdiff config1.json config2.json --ignore-case
# Ignore whitespace differences
configdiff config1.yml config2.yml --ignore-whitespaceThe tool automatically detects file formats based on extensions, but you can override:
# Force YAML parsing for files without .yml extension
configdiff config-a config-b --format yamlFor comparing multiple files, use shell scripting:
#!/bin/bash
for file in configs/*.json; do
echo "Comparing $file with production..."
configdiff "$file" "configs/production.json" -o summary
done-
Permission Denied
chmod +x bin/configdiff.js
-
Node.js Not Found
- Ensure Node.js is installed:
node --version - Install Node.js from nodejs.org
- Ensure Node.js is installed:
-
Module Not Found
- Install dependencies:
npm install - Check global installation:
npm list -g simple-config-diff
- Install dependencies:
Set DEBUG environment variable for verbose output:
DEBUG=configdiff configdiff file1.json file2.jsonThe CLI tool is part of the SimpleConfigDiff project. See the main README for contribution guidelines.
MIT License - see LICENSE file for details.