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 browser

or try sample data

What is C# List Diff?

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.

C# List Comparison — Code Examples

LINQ Except — set difference

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, mediatr

Except uses set semantics — ignores duplicates and doesn't show index positions.

SequenceEqual — order-sensitive equality

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 how

SequenceEqual returns a boolean — no detail about which elements differ.

Index-aware comparison with Zip

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 -> nunit

Zip truncates to the shorter collection — misses elements added at the end.

C# List Comparison Gotchas

Reference vs value equality

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 uses GetHashCode

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.

Null elements in collections

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.

Frequently Asked Questions

How do I compare two C# Lists online?

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.

What is the difference between SequenceEqual and Except?

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.

Can this compare Lists of objects?

Yes. Serialize your objects to JSON and paste them. The tool compares all properties recursively at any nesting depth.

Is my data safe?

Yes. This tool runs entirely in your browser. No data is transmitted to any server.

Does this work with C# arrays too?

Yes. Both T[] arrays and List<T> serialize to JSON arrays, so the comparison works identically.

Can I ignore list order?

Yes. Check "Ignore array order" to compare lists as unordered collections, similar to C# HashSet comparison.