JSON
JSON Diff / Compare
Confronto tra due documenti JSON — cosa è stato aggiunto, rimosso o modificato, con il percorso esatto di ogni differenza.
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.
Domande frequenti
Cosa fa questo strumento di confronto JSON?
Confronta due documenti JSON e mostra cosa è stato aggiunto, rimosso o modificato, indicando il percorso esatto di ogni differenza.
Perché un array che ho solo riordinato risulta "modificato"?
Il confronto tra array è basato sulla posizione (indice), quindi anche se gli elementi sono identici ma in ordine diverso, lo strumento li segnala come cambiati anziché riconoscerli come semplicemente spostati.
I due JSON che incollo vengono salvati o inviati altrove?
No, il confronto avviene interamente nel browser tramite JavaScript; i dati non vengono mai caricati su un server.
L'ordine delle chiavi di un oggetto viene considerato nel risultato del confronto?
No, il confronto strutturale guarda solo ai dati veri e propri — la presenza di un campo, il suo valore e il tipo. L'ordine delle chiavi in un oggetto JSON non è semanticamente significativo, quindi non influisce sul risultato.
Si possono confrontare gli elementi di un array per identificatore invece che per posizione?
Dipende dall'algoritmo di confronto specifico. Gli strumenti di diff più semplici confrontano sempre gli elementi dell'array per indice; quelli più avanzati cercano di abbinare gli oggetti in base a un campo comune come id, per mostrare più correttamente un inserimento o una rimozione.