JSON
JSON Diff / Compare
Porównanie dwóch dokumentów JSON — co zostało dodane, usunięte lub zmienione, z dokładną ścieżką do każdej różnicy.
Unlike a plain text diff, JSON Diff compares two documents by structure rather than by line: it understands that key order in an object doesn't matter, and it shows the exact path (e.g. user.address.city) to every difference.
How to use it
- Paste the original JSON into one field and the new version into the other.
- The result lists added, removed, and changed fields with the exact path to each and its old and new value.
- Formatting and key order don't affect the result — only the underlying data structure is compared.
Common uses
- Checking exactly what changed in an API response between two versions or two requests.
- Comparing configuration files (package.json, app settings) across branches or environments.
- Debugging a failing test by precisely comparing the expected and actual JSON output.
Things to keep in mind
Array elements are usually compared by position (index) — inserting one element near the start can show every following item as "changed", even though they merely shifted.
The comparison is structural, not textual — two JSON documents with identical data but different formatting or key order are treated as the same.
Artykuł o tym narzędziu: JSON Diff: czym porównanie strukturalne różni się od tekstowego
Najczęstsze pytania
Jak to narzędzie decyduje, co liczy się jako "różnica"?
Rekurencyjnie porównuje obie struktury JSON klucz po kluczu i indeks po indeksie, raportując dodane, usunięte i zmienione wartości — kolejność kluczy obiektu jest ignorowana, ale kolejność elementów tablicy ma znaczenie.
Dlaczego zmiana kolejności elementów tablicy pojawia się jako zmiana?
Tablice JSON są uporządkowane, więc element przesuwający się z indeksu 2 na indeks 0 jest traktowany jako usunięcie i ponowne dodanie, a nie brak zmiany, nawet jeśli wartości są identyczne.
Czy moje dane JSON są gdzieś wysyłane, aby obliczyć różnicę?
Nie. Porównanie odbywa się całkowicie w Twojej przeglądarce — żaden plik nie jest przesyłany na serwer.
Czy kolejność kluczy obiektu jest uwzględniana w wyniku porównania?
Nie, porównanie strukturalne bierze pod uwagę tylko same dane — obecność pola, jego wartość i typ. Kolejność kluczy w obiekcie JSON nie jest semantycznie istotna, więc nie wpływa na wynik.
Czy można porównywać elementy tablicy nie według pozycji, a według identyfikatora?
Zależy to od konkretnego algorytmu porównania. Proste narzędzia diff zawsze zestawiają elementy tablicy według indeksu; bardziej zaawansowane próbują dopasować obiekty według wspólnego pola, np. id, aby dokładniej pokazać wstawienie lub usunięcie.