If your shell supports process substitution (Bash-style follows, see docs):

diff <(jq --sort-keys . A.json) <(jq --sort-keys . B.json)

Objects key order will be ignored, but array order will still matter. It is possible to work-around that, if desired, by sorting array values in some other way, or making them set-like (e.g. ["foo", "bar"]{"foo": null, "bar": null}; this will also remove duplicates).

Alternatively, substitute diff for some other comparator, e.g. cmp, colordiff, or vimdiff, depending on your needs. If all you want is a yes or no answer, consider using cmp and passing --compact-output to jq to not format the output for a potential small performance increase.

Answer from Erik on Stack Overflow
🌐
GitHub
github.com › josephburnett › jd
GitHub - josephburnett/jd: JSON diff and patch · GitHub
Usage: jd [OPTION]... FILE1 [FILE2] Diff and patch JSON files. Prints the diff of FILE1 and FILE2 to STDOUT. When FILE2 is omitted the second input is read from STDIN. When patching (-p) FILE1 is a diff.
Starred by 2.2K users
Forked by 65 users
Languages   Go 97.7% | Makefile 1.2%
🌐
Jd-tool
play.jd-tool.io
jd
Read more about the diff language here. This page is a web interface for jd. Enter two JSON values in the a.json and b.json fields and the output will be shown in the diff field. Switch the Options to patch and the diff will be applied to a.json to produce b.json.
🌐
GitHub
github.com › jlevy › pdiffjson
GitHub - jlevy/pdiffjson: View and diff JSON the easy way · GitHub
Just the simplest and fastest way to format, display, and diff JSON directly from the command line.
Starred by 77 users
Forked by 6 users
Languages   Shell
🌐
Hacker News
news.ycombinator.com › item
Jd – JSON Diff and Patch | Hacker News
September 10, 2024 - The developer can always choose to use a shorted local alias for commonly used tools · That being said, I wonder if this is much better than difftastic that is more general purpose, but tree-aware? I suppose this one wouldn't care about JSON dictionary key ordering, at least
🌐
SourceForge
sourceforge.net › projects › json-diff-and-patch.mirror
JSON diff and patch download | SourceForge.net
This is an exact mirror of the JSON diff and patch project, hosted at https://github.com/josephburnett/jd.
🌐
PyPI
pypi.org › project › jsondiff
jsondiff · PyPI
jdiff [-h] [-p] [-s {compact,symmetric,explicit}] [-i INDENT] [-f {json,yaml}] first second positional arguments: first second optional arguments: -h, --help show this help message and exit -p, --patch -s {compact,symmetric,explicit}, --syntax {compact,symmetric,explicit} Diff syntax controls how differences are rendered (default: compact) -i INDENT, --indent INDENT Number of spaces to indent.
      » pip install jsondiff
    
Published   Aug 29, 2024
Version   2.2.1
🌐
GitHub
github.com › marketplace › actions › jd-json-diff-and-patch
jd - JSON diff and patch - GitHub Marketplace
Usage: jd [OPTION]... FILE1 [FILE2] Diff and patch JSON files. Prints the diff of FILE1 and FILE2 to STDOUT. When FILE2 is omitted the second input is read from STDIN. When patching (-p) FILE1 is a diff.
🌐
OpenClass
open.openclass.ai › resource › lesson-61d4cd5d0eefc550e0582e8f
OpenClass Lesson - JSON 4: JD
JSON 4: JD · Completed · Did you like this lesson? (Voting helps us personalize your learning experience!) JSON 3: JQ ·
Find elsewhere
🌐
JSON Diff
jsondiff.com
JSON Diff - The semantic JSON compare tool
Validate, format, and compare two JSON documents. See the differences between the objects instead of just the new lines and mixed up properties.
🌐
jd
jd-tool.io
jd | produce and apply JSON structural diffs
Usage: jd [OPTION]... FILE1 [FILE2] Diff and patch JSON files. Prints the diff of FILE1 and FILE2 to STDOUT. When FILE2 is omitted the second input is read from STDIN. When patching (-p) FILE1 is a diff. Options: -color Print color diff. -p Apply patch FILE1 to FILE2 or STDIN.
🌐
Medium
medium.com › @capeta1024 › json-diff-using-jq-vimdiff-b94829de40ff
JSON Diff using jq & vimdiff. JSON is a very commonly used data… | by Ankit Deshpande | Medium
September 26, 2022 - Let’s take a look at how two JSON objects be compared using some commonly used tools like JQ and Vimdiff.
🌐
Go Packages
pkg.go.dev › github.com › josephburnett › jd
jd command - github.com/josephburnett/jd - Go Packages
February 9, 2025 - Usage: jd [OPTION]... FILE1 [FILE2] Diff and patch JSON files. Prints the diff of FILE1 and FILE2 to STDOUT. When FILE2 is omitted the second input is read from STDIN. When patching (-p) FILE1 is a diff. Options: -color Print color diff. -p Apply patch FILE1 to FILE2 or STDIN.
🌐
GitHub
github.com › xlwings › jsondiff
GitHub - xlwings/jsondiff: Diff JSON and JSON-like structures in Python · GitHub
jdiff [-h] [-p] [-s {compact,symmetric,explicit}] [-i INDENT] [-f {json,yaml}] first second positional arguments: first second optional arguments: -h, --help show this help message and exit -p, --patch -s {compact,symmetric,explicit}, --syntax {compact,symmetric,explicit} Diff syntax controls how differences are rendered (default: compact) -i INDENT, --indent INDENT Number of spaces to indent.
Starred by 747 users
Forked by 89 users
Languages   Python
🌐
GitHub
gist.github.com › ipan › e5e86d5495f16216e31fe12ebc9532a4
compare two JSONs with jq #json #jq · GitHub
You can use: diff <(jq 'keys' file1.json) <(jq 'keys' file2.json) This will just give you the list of keys that are different.
🌐
Stack Overflow
stackoverflow.com › questions › 73654879 › diff-json-files-and-write-changes
python 3.x - Diff json files and write changes - Stack Overflow
So in the end you want that file 2 is identical to file 1. Calculating the differences is pointless, just make a copy of file 1. ... Sorry for the late response.. deadlines at work... ... import jsondiff as jd from jsondiff import diff # open and load files with open(one, "r") as f, open(two, "r") as f2: file_one = json.load(f) file_two = json.load(f2) # get differences in file_two (file_one being the master) differences = (file_two, file_one) # in order to access $update from differences use jd.update update = differences[jd.update] # assuming there are updates, loop through and update them accordingly for x in update: file_two.update({x : update[x]}) # Open a new file and write the updated contents of file_two outfile = open(outfile, "w") json.dump(file_two, outfile, indent=4)
🌐
GitHub
github.com › kulabun › jd
GitHub - kulabun/jd: JSON diff and patch
When patching (-p) FILE1 is a diff. Options: -p Apply patch FILE1 to FILE2 or STDIN. -o=FILE3 Write to FILE3 instead of STDOUT. -set Treat arrays as sets. -mset Treat arrays as multisets (bags). -setkeys Keys to identify set objects -yaml Read and write YAML instead of JSON. -port=N Serve web UI on port N Examples: jd a.json b.json cat b.json | jd a.json jd -o patch a.json b.json; jd patch a.json jd -set a.json b.json
Author   kulabun
🌐
Hacker News
news.ycombinator.com › item
Faster and simpler with the command line: deep-comparing JSON files with jq | Hacker News
December 17, 2018 - Btw I'm surprised you needed -M, since I thought jq would suppress colors if it saw it wasn't writing to a tty · Even when reading the article I thought about it :)
🌐
Homebrew
formulae.brew.sh › formula › jd
jd — Homebrew Formulae
brew install jd · JSON diff and patch · https://github.com/josephburnett/jd · License: MIT · Development: Pull requests · Formula JSON API: /api/formula/jd.json · Formula code: jd.rb on GitHub ·
🌐
npm
npmjs.com › package › json-diff
json-diff - npm
% json-diff --help Usage: json-diff [-vCjfonskKp] first.json second.json Arguments: <first.json> Old file <second.json> New file General options: -v, --verbose Output progress info -C, --[no-]color Colored output -j, --raw-json Display raw JSON encoding of the diff -f, --full Include the equal sections of the document, not just the deltas --max-elisions COUNT Max number of ...s to show in a row in "deltas" mode (before collapsing them) -o, --output-keys KEYS Always print this comma separated keys, with their value, if they are part of an object with any diff -x, --exclude-keys KEYS Exclude these comma separated keys from comparison on both files -n, --output-new-only Output only the updated and new key/value pairs (without marking them as such).
      » npm install json-diff
    
Published   May 15, 2023
Version   1.0.6
Author   Andrey Tarantsov