CLI Tools python Intermediate

JSON Diff CLI Tool

Compare two JSON files and highlight added, removed and changed keys.

python
import json, sys
from deepdiff import DeepDiff
from rich.console import Console
from rich import print_json

def diff(a: str, b: str):
    with open(a) as f: data_a = json.load(f)
    with open(b) as f: data_b = json.load(f)
    delta = DeepDiff(data_a, data_b, ignore_order=True).to_dict()
    Console().print_json(json.dumps(delta, default=str))

diff(sys.argv[1], sys.argv[2])

Prerequisites

  • deepdiff >= 6
  • rich >= 13

Pro Tips

  • → Use --ignore_string_case=True for case-insensitive comparison.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
python
Level
Intermediate
Read time
2 min
Published
Mar 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.