Compare Python Lists Online
Paste two Python lists (as JSON arrays). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browserLast updated
or try sample data
Paste two Python lists (as JSON arrays). See what was added, removed, or changed — element by element.
🔒 100% private — runs entirely in your browserLast updated
or try sample data
Python List Diff compares two Python lists element by element and shows you exactly what changed. Unlike Python's built-in set() difference which discards order and duplicates, this tool preserves index positions and shows additions, removals, and modifications in context.
Python lists are ordered, mutable sequences that can contain any data type — strings, numbers, nested lists, or dictionaries. When debugging data pipelines, comparing API responses, or reviewing configuration changes, seeing a visual diff of two lists is far more useful than manually scanning them.
Paste your lists as JSON arrays (e.g., [1, 2, 3]). The tool handles nested structures, mixed types, and large lists. Everything runs in your browser — your data never leaves your machine.
list_a = ["flask", "django", "requests", "numpy"]
list_b = ["flask", "fastapi", "requests", "pandas"]
added = set(list_b) - set(list_a)
removed = set(list_a) - set(list_b)
print(f"Added: {added}") # {'fastapi', 'pandas'}
print(f"Removed: {removed}") # {'django', 'numpy'}Set difference is fast but ignores element order and duplicate values.
list_a = [1, 2, 3, 4, 5]
list_b = [1, 2, 99, 4, 5, 6]
for i in range(max(len(list_a), len(list_b))):
val_a = list_a[i] if i < len(list_a) else "(missing)"
val_b = list_b[i] if i < len(list_b) else "(missing)"
if val_a != val_b:
print(f"Index {i}: {val_a} -> {val_b}")
# Index 2: 3 -> 99
# Index 5: (missing) -> 6Manual comparison works for flat lists but breaks down with nested dicts and mixed types.
from deepdiff import DeepDiff
list_a = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
list_b = [{"name": "Alice", "age": 31}, {"name": "Charlie", "age": 28}]
diff = DeepDiff(list_a, list_b)
print(diff)
# {'values_changed': {"root[0]['age']": {'new_value': 31, 'old_value': 30}, ...}}DeepDiff is powerful but requires pip install. This online tool gives you the same insight instantly.
| Gotcha | Why it happens | What to do |
|---|---|---|
| Mutable default arguments | A list used as a default argument (def fn(items=[])) is created once and shared across every call, so outputs accumulate state. | Default to None and build the list inside the function. |
| Float equality is unreliable | 0.1 + 0.2 == 0.3 is False in Python because binary floating point cannot represent those decimals exactly. | Round with round() or compare with math.isclose() before diffing lists of floats. |
| Lists and tuples never compare equal | [1, 2, 3] == (1, 2, 3) is False — the types differ even when the elements match. | Convert tuples to lists before pasting: (1, 2, 3) becomes [1, 2, 3]. |
Ordered comparison is linear and stays in single-digit milliseconds even at 50,000 elements. Ignoring order is O(n2.077) because every element is scored against every remaining candidate, so cost rises roughly fourfold each time the array doubles.
| Elements | Ordered | Ignore order |
|---|---|---|
| 1,000 | 0.20 ms | 5.2 s |
| 10,000 | 1.10 ms | ~10 min * |
| 50,000 | 5.67 ms | ~4.8 hr * |
You should land here first if your task already names this workflow. The examples, defaults, and answers on Compare Python Lists Online assume that context.
If your task is more general or you have not narrowed down the workflow yet, start in the Array Comparison Tools and let it route you to the right page.
Paste your Python lists into the two panels using JSON array syntax (e.g., [1, 2, 3]) and click Compare. The tool highlights added, removed, and modified elements with color-coded diffs.
Yes. The tool performs deep comparison of nested lists, dictionaries, and mixed structures at any depth. Nested changes are shown with path-based highlighting.
A set difference (set(a) - set(b)) only tells you which elements exist in one set but not another, discarding order and duplicates. A list diff preserves index positions and shows exactly which elements changed at each position.
Yes. This tool runs entirely in your browser using client-side JavaScript. Your data is never sent to any server, making it safe for comparing sensitive data.
Yes. Convert Python dicts to JSON objects (they use the same {"key": "value"} syntax). The tool compares them structurally at any nesting depth.
Yes. Check the "Ignore array order" option to compare lists as unordered collections, similar to comparing Python sets but with support for duplicates and nested structures.
Compare flat arrays, nested arrays, arrays of objects, and language-specific list structures with pages that focus on one job at a time.
Need more context before using the tool? Start with one of these workflow guides.