Compare Java Arrays Online
Paste two Java arrays or collections (as JSON). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browseror try sample data
Paste two Java arrays or collections (as JSON). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browseror try sample data
Java Array Compare diffs two Java arrays or collections element by element. Java's == operator compares references, not values, and even Arrays.equals() only checks one level deep. This tool shows you a full visual diff with nested comparison.
Java has two kinds of array-like structures: primitive arrays (int[], String[]) and Collections (ArrayList, LinkedList). Both can be serialized to JSON for comparison. Whether you're debugging Spring Boot responses, comparing test fixtures, or reviewing Hibernate query results, visual diffs save time.
Serialize your data with Gson (new Gson().toJson(list)) or Jackson (mapper.writeValueAsString(list)) and paste it here. The tool handles nested objects, arrays, and mixed types.
import java.util.Arrays; String[] arr1 = {"spring", "hibernate", "junit"};
String[] arr2 = {"spring", "hibernate", "junit"}; System.out.println(Arrays.equals(arr1, arr2)); // true // But for nested arrays:
int[][] nested1 = {{1, 2}, {3, 4}};
int[][] nested2 = {{1, 2}, {3, 4}};
System.out.println(Arrays.equals(nested1, nested2)); // false!Arrays.equals does not recurse into nested arrays. Use Arrays.deepEquals for that.
import java.util.Arrays; Object[][] arr1 = {{"a", 1}, {"b", 2}};
Object[][] arr2 = {{"a", 1}, {"b", 3}}; System.out.println(Arrays.deepEquals(arr1, arr2)); // false // Still only returns boolean — no detail on what changeddeepEquals tells you whether arrays are equal but not where the differences are.
import java.util.*;
import java.util.stream.*; List<String> list1 = List.of("spring", "hibernate", "junit", "maven");
List<String> list2 = List.of("spring", "quarkus", "junit", "gradle"); Set<String> set1 = new HashSet<>(list1);
Set<String> set2 = new HashSet<>(list2); Set<String> added = set2.stream() .filter(e -> !set1.contains(e)) .collect(Collectors.toSet());
// [quarkus, gradle]Stream-based diffing works for flat collections but ignores index positions and nested objects.
In Java, arr1 == arr2 checks if both variables point to the same array object in memory. Even if two arrays contain identical elements, == returns false. Always use Arrays.equals() or Arrays.deepEquals().
Integer values between -128 and 127 are cached, so Integer.valueOf(127) == Integer.valueOf(127) is true. But Integer.valueOf(128) == Integer.valueOf(128) is false. This can cause unexpected results when comparing arrays of boxed integers.
ArrayList.equals() does element-by-element comparison using .equals(), which is correct. But Arrays.equals() on Object[] also uses .equals(), while == on arrays compares references. Know which comparison method your code is using.
Serialize your arrays to JSON using Gson or Jackson and paste the JSON into the two panels. Click Compare to see element-by-element differences.
== in Java compares object references (memory addresses), not contents. Two arrays with identical elements are different objects, so == returns false. Use Arrays.equals() or Arrays.deepEquals().
Yes. Serialize your ArrayList to JSON and paste it. JSON arrays map directly to Java Lists.
Yes. This tool runs entirely in your browser. No data is transmitted to any server.
Yes. Serialize records or POJOs to JSON with any Java JSON library. All fields will be compared recursively.
Yes. Check the "Ignore array order" option to compare arrays as unordered collections, similar to comparing Java Sets.