How to use JSON Diff and Patch
- Paste the document you have now into Original JSON and the document you want into Updated JSON.
- Pick how the patch should be indented. Compact output is a single line; 2 or 4 spaces are easier to read.
- Read the change list, then copy the patch below and apply it to the original document to get the updated one.
Example: JSON Diff and Patch
Compare a user record after a role was added and a flag was cleared.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Why the patch is built from structure, not lines
A line diff is useful when you read it, but it cannot be applied to a data structure. Json Patch names each value by a JSON Pointer, so an operation says exactly which key or index to change. That is why the tool compares values instead of text: the same document written with different spacing, key order or line breaks still compares as equal, and only real value changes appear in the patch.
Questions about JSON Diff and Patch
Why did adding one item in the middle change several lines of the patch?
The comparison works by position, the way JSON Patch indexes array members. Adding an item in the middle shifts everything after it, so each shifted value shows as a replace at its old index. The patch still rebuilds the updated document exactly.
Do whitespace, key order or array order affect the patch?
Formatting, key order and line breaks are ignored, because the comparison looks at values. Array order is part of the value, so two lists with the same entries in a different order still differ, and the patch reports that as a run of replaces. Move the entries into the same order first if the order does not matter to you.
What happens to very large integers and decimals?
Numbers are handled as standard JavaScript doubles. The tool refuses an integer larger than 9007199254740991 or a value that parses to Infinity, because storing or printing it again would change it. Keep those values as strings. Decimals carry normal floating point precision, so compare money as strings or scaled integers if the exact last digit matters.
Is the patch checked before I copy it?
Yes. The tool applies the patch to the original document and compares the result with the updated document. If they differ, it reports that and returns nothing. Your two inputs stay in this browser.