Compare C# Lists Online
Paste two C# Lists or arrays (as JSON). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browseror try sample data
Paste two C# Lists or arrays (as JSON). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browseror try sample data
C# List Diff compares two C# Lists or arrays element by element and shows exactly what changed. While LINQ provides Except() and SequenceEqual(), neither gives you a visual, position-aware diff showing additions, removals, and modifications side by side.
C# offers several collection types: List<T>, arrays (T[]), IEnumerable<T>, and more. All serialize to JSON arrays. When debugging ASP.NET API responses, comparing Entity Framework results, or reviewing configuration changes, a visual diff tool is essential.
Serialize your data with System.Text.Json.JsonSerializer.Serialize() or JsonConvert.SerializeObject() (Newtonsoft.Json) and paste it here. The tool handles nested objects, arrays, and mixed types.
var list1 = new List<string> { "aspnet", "efcore", "xunit", "serilog" };
var list2 = new List<string> { "aspnet", "efcore", "nunit", "serilog", "mediatr" }; var removed = list1.Except(list2).ToList();
var added = list2.Except(list1).ToList(); Console.WriteLine($"Removed: {string.Join(", ", removed)}"); // xunit
Console.WriteLine($"Added: {string.Join(", ", added)}"); // nunit, mediatrExcept uses set semantics — ignores duplicates and doesn't show index positions.
var list1 = new List<int> { 1, 2, 3, 4 };
var list2 = new List<int> { 1, 2, 3, 5 }; bool equal = list1.SequenceEqual(list2);
Console.WriteLine(equal); // False // Tells you they differ, but not where or howSequenceEqual returns a boolean — no detail about which elements differ.
var list1 = new[] { "aspnet", "efcore", "xunit" };
var list2 = new[] { "aspnet", "efcore", "nunit", "mediatr" }; var pairs = list1.Zip(list2, (a, b) => new { a, b });
foreach (var (pair, i) in pairs.Select((p, i) => (p, i)))
{ if (pair.a != pair.b) Console.WriteLine($"[{i}]: {pair.a} -> {pair.b}");
}
// [2]: xunit -> nunitZip truncates to the shorter collection — misses elements added at the end.
By default, == on reference types compares object references, not property values. Two objects with identical properties are not equal unless you override Equals() and GetHashCode(), or implement IEquatable<T>. For LINQ methods like Except(), pass a custom IEqualityComparer<T>.
Except() relies on GetHashCode() for performance. If your custom class doesn't override it, every object has a unique hash and Except() treats all objects as different — even when their properties match.
C# lists can contain null elements. LINQ methods handle nulls gracefully, but serializing to JSON turns null into the JSON literal null. Be aware that null in your list will appear as null in the JSON comparison.
Serialize your Lists to JSON using System.Text.Json or Newtonsoft.Json and paste the JSON into the two panels. Click Compare to see element-by-element differences.
SequenceEqual() checks if two sequences have the same elements in the same order (returns boolean). Except() returns elements in the first sequence not in the second (set difference). Neither provides a full visual diff.
Yes. Serialize your objects to JSON and paste them. The tool compares all properties recursively at any nesting depth.
Yes. This tool runs entirely in your browser. No data is transmitted to any server.
Yes. Both T[] arrays and List<T> serialize to JSON arrays, so the comparison works identically.
Yes. Check "Ignore array order" to compare lists as unordered collections, similar to C# HashSet comparison.