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