By default DeepDiff ignores private variables. These are field names that start with double underscore.

You can test this by adding a letter to the start of the underscore.

Anyway to preform comparison, simply set the parameter ignore_private_variables to False

That is:

print(DeepDiff(item1, item2, ignore_private_variables=False))

Output:

{'dictionary_item_added': [root['__PythonResult__Modules']['global']], 'dictionary_item_removed': [root['__PythonResult__Modules']['b']]}
Answer from Greg on Stack Overflow
🌐
Zepworks
zepworks.com › deepdiff › current › serialization.html
Serialization — DeepDiff 8.6.1 documentation
Take a look at the above To Json Pickle for an example. Sometimes, it is desired to serialize a Delta object to a list of flat rows. For example, to store them in relation databases. In that case, you can use the Delta.to_flat_rows to achieve the desired outcome. The rows are named tuples and can be converted to dictionaries using ._asdict() >>> from pprint import pprint >>> from deepdiff import DeepDiff, Delta >>> t1 = {"key1": "value1"} >>> t2 = {"field2": {"key2": "value2"}} >>> diff = DeepDiff(t1, t2, verbose_level=2) >>> pprint(diff, indent=2) { 'dictionary_item_added': {"root['field2']":
🌐
Medium
medium.com › @ssspidersilk › debugging-with-deepdiff-deep-differences-in-python-json-dicts-objects-51b5647d4ea9
Debugging with DeepDiff: Deep Differences in Python JSON, Dicts, & Objects | by Jerry | Medium
April 22, 2023 - As we can see, DeepDiff has identified the differences between the two JSON objects, including changes in values and added or removed dictionary items.
🌐
PyPI
pypi.org › project › deepdiff
deepdiff · PyPI
Deep Difference and Search of any Python object/data. Recreate objects by adding adding deltas to each other.
      » pip install deepdiff
    
Published   Sep 03, 2025
Version   8.6.1
🌐
Deviloper's Blog
deviloper.in › advanced-json-diff-checker-in-python-an-in-depth-guide
Advanced JSON Diff Checker in Python: An In-Depth Guide
September 9, 2024 - In this comprehensive guide, we'll dive into the world of JSON diff checking and explore how to build an advanced JSON diff checker in Python. We'll leverage the power of the deepdiff library to perform precise comparisons and the termcolor library to provide a visually appealing and user-friendly output.
🌐
Readthedocs
deepdiff.readthedocs.io › en › latest › diff.html
DeepDiff Reference — DeepDiff 4.0.7 documentation
Load DeepDiff object with all the bells and whistles from the json pickle dump.
🌐
GitHub
github.com › seperman › deepdiff
GitHub - seperman/deepdiff: DeepDiff: Deep Difference and search of any Python object/data. DeepHash: Hash of any object based on its contents. Delta: Use deltas to reconstruct objects by adding deltas together.
DeepDiff: Deep Difference of dictionaries, iterables, strings, and ANY other object. DeepSearch: Search for objects within other objects. DeepHash: Hash any object based on their content.
Starred by 2.5K users
Forked by 257 users
Languages   Python
Find elsewhere
🌐
Readthedocs
deepdiff.readthedocs.io
DeepDiff OLD 4.0.7 documentation! — DeepDiff 4.0.7 documentation
DeepDiff: Deep Difference of dictionaries, iterables, strings and other objects.
🌐
YouTube
youtube.com › watch
1. DeepDiff: Smarter JSON Comparison using Python - YouTube
Learn how to compare JSON like a pro using DeepDiff in Python! 🚀In this episode, we introduce DeepDiff—a powerful tool for QAs and developers to detect chan...
Published   October 22, 2025
🌐
Zepworks
zepworks.com › deepdiff › current › index.html
DeepDiff 8.6.1 documentation! — DeepDiff 8.6.1 documentation
Get the deep difference of any Python objects. ... DeepDiff For Deep Difference of 2 objects.
🌐
GitHub
github.com › seperman › deepdiff › issues › 566
JSON serialization doesn't work when DeepDiff is part of another dict · Issue #566 · seperman/deepdiff
September 4, 2025 - import json from deepdiff import DeepDiff d1 = dict(a=1, b=2, c=3) d2 = dict(a=1, b=2, c=4, e="new") diff = DeepDiff(d1, d2) print(diff.to_json()) # works fine # --- some_bigger_object = {"diffs": diff} class DeepDiffToDictEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, DeepDiff): return o.to_dict() return super().default(o) class DeepDiffToJsonEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, DeepDiff): return o.to_json() return super().default(o) # raises TypeError: Object of type SetOrdered is not JSON serializable print(json.dumps(some_bigger_object, cls=DeepDiffToDictEncoder)) # raises TypeError: Object of type SetOrdered is not JSON serializable print(json.dumps(some_bigger_object, cls=DeepDiffToJsonEncoder))
Published   Sep 04, 2025
🌐
Medium
medium.com › @abedmaatalla › compare-two-json-objects-python-c2f763c943b0
Compare two JSON objects (Python) | by Abed MAATALLA | Medium
August 4, 2022 - DeepDiff function of deepdiff module returns all the changes, let's find all differences using deepdiff: Output: result is a dictionary which contains all differences. ... We have seen easiest way to compare and find the differences in json objects.
🌐
Snyk
snyk.io › advisor › deepdiff › functions › deepdiff.deepdiff
How to use the deepdiff.DeepDiff function in deepdiff | Snyk
So first, if there is a Policy attribute, do a DeepDiff of just the JSON parsed from the strings of both, then if they match, remove the elements from the dictionaries. Then there is another DeepDiff on the rest of the state, which wont fail erroneously now that the policy strings have been removed.
🌐
Thenerdnook
thenerdnook.io › p › python-deepdiff-tutorial-spot-differences
DeepDiff in Python Explained: Find Data Changes Fast Without Manual Checks
September 3, 2025 - Learn how to use Python DeepDiff to quickly compare dictionaries, lists, and JSON data. Spot changes fast, save time debugging, and simplify data analysis.
🌐
GitHub
github.com › RafiC92 › deepdiff
GitHub - RafiC92/deepdiff: Deep Difference and search of any Python object/data.
Deep Difference of dictionaries, iterables, strings and other objects. It will recursively look for all the changes. Tested on Python 2.7, 3.3, 3.4, 3.5, 3.6, Pypy, Pypy3 ... >>> from deepdiff import DeepDiff # For Deep Difference of 2 objects >>> from deepdiff import DeepSearch # For finding if item exists in an object
Author   RafiC92
🌐
Zepworks
zepworks.com › deepdiff › current › optimizations.html
Optimizations — DeepDiff 8.6.1 documentation
DeepDiff will automatically use orjson instead of Python’s built-in json library to do json serialization.
🌐
Read the Docs
media.readthedocs.org › pdf › deepdiff › latest › deepdiff.pdf pdf
DeepDiff Documentation Release 4.0.7 Sep Dehpour Oct 12, 2021
In order to convert the DeepDiff object into a normal Python dictionary, use the to_dict() method. Note that · to_dict will use the text view even if you did the diff in tree view. ... In order to do safe json serialization, use the to_json() method.