A semantic configuration comparison tool for infrastructure and application configs. Compare YAML, JSON, TOML, and INI files intelligently - detecting meaningful differences while ignoring formatting and ordering variations.
- 🎯 Semantic Comparison: Compares configuration semantics, not just text
- 📝 Multiple Formats: Supports YAML, JSON, TOML, and INI files
- 🎨 Colored Output: Beautiful, easy-to-read colored diffs in terminal
- 📊 Machine-Readable: JSON output for integration with other tools
- 🔄 Order-Independent: Ignores key ordering in maps/objects
- 🧩 Nested Structures: Deep comparison of nested configurations
- 📈 Change Summary: Quick overview of additions, removals, and modifications
go install github.com/BaseMax/go-config-diff/cmd/go-config-diff@latestgit clone https://github.com/BaseMax/go-config-diff.git
cd go-config-diff
go build -o go-config-diff ./cmd/go-config-diffgo-config-diff config1.yaml config2.yamlDisplays changes with color-coded indicators:
- 🟢 Green
+for additions - 🔴 Red
-for removals - 🟡 Yellow
~for modifications
go-config-diff config1.yaml config2.yamlFor environments without color support:
go-config-diff -format=plain config1.json config2.jsonMachine-readable format for automation:
go-config-diff -format=json config1.toml config2.tomlDisplay a summary of changes:
go-config-diff -summary config1.ini config2.inigo-config-diff -version$ go-config-diff examples/config1.yaml examples/config2.yaml
~ database.credentials.password
- "secret123"
+ "newsecret456"
~ database.name
- "myapp"
+ "myapp_prod"
+ features[3]
+ "caching"
+ server.timeout
+ 60$ go-config-diff -format=json examples/config1.json examples/config2.json
{
"has_changes": true,
"changes": [
{
"type": "modified",
"path": "database.name",
"old_value": "myapp",
"new_value": "myapp_prod"
},
{
"type": "added",
"path": "server.timeout",
"new_value": 60
}
]
}$ go-config-diff -summary examples/config1.toml examples/config2.toml
Summary: 2 added, 5 modified
~ database.name
- "myapp"
+ "myapp_prod"
+ features[3]
+ {"name":"caching"}| Format | Extensions | Description |
|---|---|---|
| YAML | .yaml, .yml |
YAML Ain't Markup Language |
| JSON | .json |
JavaScript Object Notation |
| TOML | .toml |
Tom's Obvious, Minimal Language |
| INI | .ini, .conf |
Initialization files |
- Parse: Each configuration file is parsed using format-specific parsers
- Normalize: Data is converted to a unified internal AST (Abstract Syntax Tree)
- Compare: Semantic comparison detects actual differences
- Report: Changes are formatted for human or machine consumption
- Semantic Comparison: Compares actual values, not file formatting
- Type Awareness: Understands different data types (strings, numbers, booleans, arrays, maps)
- Deep Traversal: Compares nested structures at any depth
- Path Tracking: Shows exact location of changes using dot notation
- Order Independence: Map/object key ordering doesn't affect comparison
0: No differences found1: Differences found or error occurred
Usage: go-config-diff [options] <file1> <file2>
Options:
-format string
Output format: colored, plain, json (default "colored")
-summary
Show summary of changes
-version
Show version information
- 🔧 DevOps: Compare configuration files across environments
- 🚀 CI/CD: Validate configuration changes in pipelines
- 🔍 Auditing: Review configuration differences for compliance
- 🐛 Debugging: Identify configuration drift between systems
- 📦 Releases: Verify configuration changes before deployment
go test ./... -vgo-config-diff/
├── cmd/
│ └── go-config-diff/ # CLI application
│ └── main.go
├── pkg/
│ ├── ast/ # Unified AST model
│ │ ├── ast.go
│ │ └── ast_test.go
│ ├── parser/ # Format parsers
│ │ ├── parser.go
│ │ └── parser_test.go
│ ├── diff/ # Comparison logic
│ │ ├── diff.go
│ │ └── diff_test.go
│ └── output/ # Output formatters
│ └── output.go
├── examples/ # Sample config files
└── README.md
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Max Base