Skip to content

Instantly share code, notes, and snippets.

@jlevy
Created May 28, 2019 01:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlevy/da0fbeadc20ce1547967314fb5da07d5 to your computer and use it in GitHub Desktop.
Save jlevy/da0fbeadc20ce1547967314fb5da07d5 to your computer and use it in GitHub Desktop.
Command-line JSON diff (colorized and with normalized key ordering)
#!/bin/bash
set -euo pipefail
file1="${1:?
Usage: $(basename $0) file1.json file2.json
Show diff of JSON, normalizing key ordering.
}"
file2="${2:?Missing file2}"
diff <(jq --sort-keys . < "$file1") <(jq --sort-keys . < "$file2") | colordiff | less -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment