0

I am looking for a similar tool like JSON diff tool but with the additional requirement that the tool works offline. I am asking a new question, because many answers over there do also not fit the requirements requested by OP.

I need:

  • gratis, free of cost, open source preferred. And I mean really gratis forever, not a 30 day trial version. Also gratis for commercial use.
  • Windows 10 and 11
  • offline. My data must not be sent to the Internet.
  • compares JSON with JSON in mind, i.e.
    • order of key/value pairs is irrelevant
    • whitespace outside of values is irrelevant
    • order of arrays is relevant
  • Either displays the difference directly (program has a GUI) or mangles the two JSON files in a way that a standard Difftool can compare it.
5
  • linux has system "diff" command. I believe it is in all linux distros. It is offline no internet. I see you want windows but perhaps you can get access to "diff" through the linux in windows.
    – tckosvic
    Mar 13 at 14:29
  • @tckosvic: and you think the Linux diff tool will consider the sorting of JSON? Mar 13 at 14:40
  • 1
    Not a proper tool, but I was using JSONedit to reformat files, setting JSON elements order to alphabetical and text formatting to "styled" in settings to "normalize" JSON (same can be done with just json-cpp that is underneath) and then just a regular text diff.
    – TMSZ
    Mar 15 at 9:40
  • @TMSZ: I think it qualifies as "mangles the two JSON files in a way that a standard Difftool can compare it.". It's a bit sad that it doesn't have Unicode support yet. Mar 15 at 11:01
  • Unicode would not matter in this case, but I would suggest some DIY that would make it more convenient: small application that accepts two files through drag-and-drop, normalizes JSON (e.g. using json-cpp) creating two temporary files and launches some diff tool (WinMerge maybe?) passing temporary file names to it.
    – TMSZ
    Mar 15 at 12:31

1 Answer 1

0

Use jq to first sort all keys. Then diff to do the diffing:

jq -S . A.json > A-sorted.json
jq -S . B.json > B-sorted.json
diff A-sorted.json B-sorted.json

The above example is for Linux but both jq and diff is available for Windows. It seems Windows has an alternative diff tool called fc, perhaps this could be used instead of diff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.