Philiprehberger.ConfigDiff 0.3.0

dotnet add package Philiprehberger.ConfigDiff --version 0.3.0
                    
NuGet\Install-Package Philiprehberger.ConfigDiff -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Philiprehberger.ConfigDiff" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.ConfigDiff" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.ConfigDiff" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.ConfigDiff --version 0.3.0
                    
#r "nuget: Philiprehberger.ConfigDiff, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Philiprehberger.ConfigDiff@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.ConfigDiff&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.ConfigDiff&version=0.3.0
                    
Install as a Cake Tool

Philiprehberger.ConfigDiff

CI NuGet Last updated

Philiprehberger.ConfigDiff

Structured diff for JSON configuration files — detect added, removed, changed, and unchanged keys.

Installation

dotnet add package Philiprehberger.ConfigDiff

Usage

using Philiprehberger.ConfigDiff;

var jsonA = """
{
  "Logging": { "Level": "Warning" },
  "ConnectionStrings": { "Default": "Server=old" },
  "FeatureFlag": false
}
""";

var jsonB = """
{
  "Logging": { "Level": "Information" },
  "ConnectionStrings": { "Default": "Server=old" },
  "NewSetting": "hello"
}
""";

ConfigDiffResult diff = ConfigComparer.Compare(jsonA, jsonB);

foreach (var key in diff.Added)
    Console.WriteLine($"+ {key}");

foreach (var key in diff.Removed)
    Console.WriteLine($"- {key}");

foreach (var change in diff.Changed)
    Console.WriteLine($"~ {change.Path}: '{change.OldValue}' -> '{change.NewValue}'");

// Output:
// + NewSetting
// - FeatureFlag
// ~ Logging.Level: 'Warning' -> 'Information'

Compare files

var diff = ConfigComparer.CompareFiles("appsettings.json", "appsettings.Production.json");

Compare streams

using var streamA = File.OpenRead("appsettings.json");
using var streamB = File.OpenRead("appsettings.Production.json");
var diff = ConfigComparer.Compare(streamA, streamB);

Ignore paths

Use ignorePaths to exclude specific keys from the comparison. Supports exact matches and wildcard prefix matches with .*:

var diff = ConfigComparer.Compare(jsonA, jsonB, ignorePaths: new[]
{
    "Logging.*",           // ignore everything under Logging
    "ConnectionStrings.*"  // ignore everything under ConnectionStrings
});

// Only NewSetting and FeatureFlag will appear in the result

Rich change entries

Changed entries include both the old and new values via the ConfigChange record:

foreach (var change in diff.Changed)
{
    Console.WriteLine($"{change.Path}: {change.OldValue} -> {change.NewValue}");
}

API

ConfigComparer

Method Description
Compare(string jsonA, string jsonB, IEnumerable<string>? ignorePaths = null) Diff two JSON strings
CompareFiles(string pathA, string pathB, IEnumerable<string>? ignorePaths = null) Read files from disk and diff them
Compare(Stream streamA, Stream streamB, IEnumerable<string>? ignorePaths = null) Read streams and diff them

ConfigDiffResult

Property Type Description
Added IReadOnlyList<string> Keys present in B but not in A
Removed IReadOnlyList<string> Keys present in A but not in B
Changed IReadOnlyList<ConfigChange> Keys present in both with different values
Unchanged IReadOnlyList<string> Keys with identical values
TotalChanges int Total count of added + removed + changed entries
HasDifferences bool true when any difference exists

ConfigChange

Property Type Description
Path string Dot-notation key path
OldValue string? Value in A
NewValue string? Value in B

Development

dotnet build src/Philiprehberger.ConfigDiff.csproj --configuration Release

Support

If you find this project useful:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 197 5/31/2026
0.2.8 153 4/1/2026
0.2.7 144 3/27/2026
0.2.6 136 3/25/2026
0.2.5 128 3/23/2026
0.2.4 132 3/23/2026
0.2.3 156 3/16/2026
0.2.2 132 3/16/2026
0.2.1 139 3/16/2026
0.2.0 136 3/13/2026
0.1.1 146 3/11/2026
0.1.0 147 3/11/2026