# Python diff libraries

Python diff libraries compare two strings, documents, or data structures and describe what changed between them. A structural diff reports each change by its path inside nested data rather than as inserted and deleted characters. These libraries let apps and AI agents show what changed between two versions of a record or document.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [RapidFuzz](#rapidfuzz) | 143.8M | 4.2K | Aug 2026 | MIT |
| [JSON Patch](#jsonpatch) | 137.3M | 500 | Nov 2026 | BSD-3-Clause |
| [DeepDiff](#deepdiff) | 62.8M | 2.5K | Nov 2026 | MIT |
| [Levenshtein](#levenshtein) | 20.5M | 401 | Sep 2026 | GPL-2.0-or-later |
| [jsondiff](#jsondiff) | 7.1M | 751 | Aug 2024 | MIT |
| [Diff Match Patch](#diff-match-patch) | 6.8M | 59 | Oct 2024 | Apache-2.0 |
| [dictdiffer](#dictdiffer) | 5.8M | 849 | Jul 2026 | MIT |
| [xmldiff](#xmldiff) | 345.8K | 231 | Jun 2026 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[JSON Patch](#jsonpatch) has the most monthly downloads among the dedicated diff libraries in this comparison, at 137.3M.

## Capabilities

| Library | JSON object diff | Patch without target |
| --- | --- | --- |
| [RapidFuzz](#rapidfuzz) | No | No |
| [JSON Patch](#jsonpatch) | Yes | Yes |
| [DeepDiff](#deepdiff) | Yes | Yes |
| [Levenshtein](#levenshtein) | No | No |
| [jsondiff](#jsondiff) | Yes | Yes |
| [Diff Match Patch](#diff-match-patch) | No | Yes |
| [dictdiffer](#dictdiffer) | Yes | Yes |
| [xmldiff](#xmldiff) | No | Yes |

## Libraries

### RapidFuzz

[GitHub](https://github.com/rapidfuzz/RapidFuzz) · [PyPI](https://pypi.org/project/rapidfuzz) · [Docs](https://rapidfuzz.github.io/RapidFuzz/)

Matches strings with fast fuzzy comparison.

- Downloads / mo: 143.8M
- Stars: 4.2K
- Last release: 3.14.6
- License: MIT
- Capabilities: [From the RapidFuzz docs](https://rapidfuzz.github.io/RapidFuzz/)

```sh
pip install rapidfuzz
```

**daymade/claude-code-skills** (1.5K stars)

[daymade/claude-code-skills](https://github.com/daymade/claude-code-skills) 

```python
def extract_changes(self, original: str, corrected: str) -> List[ExtractedChange]:
    """
    Extract all from→to changes between original and corrected text

    Args:
        original: Original text (before correction)
        corrected: Corrected text (after AI processing)

    Returns:
        List of ExtractedChange objects with context and confidence

    Raises:
        InputValidationError: If input validation fails

    CRITICAL FIX (P1-2): Comprehensive input validation to prevent:
    - DoS attacks from oversized input
    - Crashes from None/invalid input
    - Performance issues from malicious input
    """
    # CRITICAL FIX: Validate input types
    if not isinstance(original, str):
        raise InputValidationError(
            f"original must be str, got {type(original).__name__}"
        )

    if not isinstance(corrected, str):
        raise InputValidationError(
            f"corrected must be str, got {type(corrected).__name__}"
        )

    # CRITICAL FIX: Validate input length (DoS prevention)
    if len(original) > MAX_TEXT_LENGTH:
        raise InputValidationError(
            f"original text too long ({len(original)} chars). "
            f"Maximum allowed: {MAX_TEXT_LENGTH}"
        )

    if len(corrected) > MAX_TEXT_LENGTH:
        raise InputValidationError(
            f"corrected text too long ({len(corrected)} chars). "
            f"Maximum allowed: {MAX_TEXT_LENGTH}"
        )

    # CRITICAL FIX: Handle empty strings gracefully
    if not original and not corrected:
        logger.debug("Both texts are empty, returning empty changes list")
        return []

    # CRITICAL FIX: Validate text contains valid characters (not binary data)
    try:
        # Try to encode/decode to ensure valid text
        original.encode('utf-8')
        corrected.encode('utf-8')
    except UnicodeError as e:
        raise InputValidationError(f"Invalid text encoding: {e}") from e

    logger.debug(
        f"Extracting changes: original={len(original)} chars, "
        f"corrected={len(corrected)} chars"
    )

    original_tokens = self._tokenize(original)
    corrected_tokens = self._tokenize(corrected)
    opcodes = self._coalesce_opcodes(Levenshtein.opcodes(
        [token for token, _start, _end in original_tokens],
        [token for token, _start, _end in corrected_tokens],
    ).as_list())
    changes = []
    seen: set[tuple[int, str, str]] = set()

    for tag, i1, i2, j1, j2 in opcodes:
        if tag != 'equal':
            original_start, original_end = self._token_span(
                original_tokens, i1, i2, len(original)
            )
            corrected_start, corrected_end = self._token_span(
                corrected_tokens, j1, j2, len(corrected)
            )

            learnable = tag == 'replace'
            if tag == 'insert':
                (
                    original_start,
                    original_end,
                    corrected_start,
                    corrected_end,
                    learnable,
                ) = self._anchor_insert(
                    original_tokens,
                    corrected_tokens,
                    i1,
                    j1,
                    j2,
                    original_start,
                    original_end,
                    corrected_start,
                    corrected_end,
                )
            elif tag == 'delete':
                (
                    original_start,
                    original_end,
                    corrected_start,
                    corrected_end,
                    learnable,
                ) = self._anchor_delete(
                    original_tokens,
                    corrected_tokens,
                    i1,
                    i2,
                    j1,
                    original_start,
                    original_end,
                    corrected_start,
                    corrected_end,
                )

            from_text = original[original_start:original_end]
            to_text = corrected[corrected_start:corrected_end]

            if not self._is_material_change(from_text, to_text):
                continue
            learnable_length = self._is_learnable_change_length(
                from_text, to_text
            )

            formatting_only = self._is_formatting_only(from_text, to_text)

            # Extract context
            context_before = original[max(0, original_start-20):original_start]
            context_after = original[
                original_end:min(len(original), original_end+20)
            ]

            # Classify change type
            change_type = self._classify_change(
                tag, from_text, to_text, formatting_only=formatting_only
            )

            # Calculate confidence (based on text similarity and context)
            confidence = self._calculate_confidence(
                from_text, to_text, context_before, context_after
            )

            # Keep the exact bytes of an unexpected whitespace/case edit in
            # history. Ordinary lexical changes still shed boundary space
            # so their replayable dictionary pair is not indentation-bound.
            clean_from = from_text if formatting_only else from_text.strip()
            clean_to = to_text if formatting_only else to_text.strip()
            key = (original_start, clean_from, clean_to)
            if key in seen:
                continue
            seen.add(key)

            changes.append(ExtractedChange(
                from_text=clean_from,
                to_text=clean_to,
                context_before=context_before,
                context_after=context_after,
                position=original_start,
                change_type=change_type,
                confidence=confidence,
                learnable=(
                    learnable
                    and learnable_length
                    and not formatting_only
                    and bool(clean_from)
                    and bool(clean_to)
                    and self._contains_lexical_text(clean_from)
                    and self._contains_lexical_text(clean_to)
                ),
            ))

            # CRITICAL FIX: Prevent DoS from excessive changes
            if len(changes) > MAX_CHANGES:
                raise InputValidationError(
                    "Correction produced more than "
                    f"{MAX_CHANGES} auditable changes; refusing to truncate "
                    "history for modified text"
                )

    logger.debug(f"Extracted {len(changes)} changes")
    return changes

```

[daymade-audio/transcript-fixer/scripts/core/change_extractor.py](https://github.com/daymade/claude-code-skills/blob/2393e2e5a82e441c578928bfb10fd9b37b553d18/daymade-audio/transcript-fixer/scripts/core/change_extractor.py#L133-L315) · [More projects using RapidFuzz →](https://dashboard.exa.ai/playground/search?q=rapidfuzz%20GitHub%20projects)

**Quickstart**

```python
from rapidfuzz.distance import Levenshtein

print(Levenshtein.editops("spam", "park"))

```

From [Levenshtein.html](https://rapidfuzz.github.io/RapidFuzz/Usage/distance/Levenshtein.html)

### JSON Patch

[GitHub](https://github.com/stefankoegl/python-json-patch) · [PyPI](https://pypi.org/project/jsonpatch) · [Docs](https://python-json-patch.readthedocs.io/)

Creates and applies JSON Patch operation sequences between JSON documents.

- Downloads / mo: 137.3M
- Stars: 500
- Last release: 1.47
- License: BSD-3-Clause
- Capabilities: [From the JSON Patch docs](https://python-json-patch.readthedocs.io/)

**Strengths**

- **Creates patches from document differences.** Use make_patch to turn a source document into its destination.
- **Can check values before replacement.** Enable generate_test_ops to detect changed values before applying a patch.

**Watch out for**

- **Patch paths depend on source.** Apply generated operations to the source document they were created from.
- **In-place operations change the input.** Keep the default copy when the original document must remain unchanged.

```sh
pip install jsonpatch
```

**langchain-ai/langchain** (149.7K stars)

[langchain-ai/langchain](https://github.com/langchain-ai/langchain) 

```python
def __add__(self, other: RunLogPatch | Any) -> RunLog:
    """Combine two `RunLogPatch` instances.

    Args:
        other: The other `RunLogPatch` to combine with.

    Raises:
        TypeError: If the other object is not a `RunLogPatch`.

    Returns:
        A new `RunLog` representing the combination of the two.
    """
    if type(other) is RunLogPatch:
        ops = self.ops + other.ops
        state = jsonpatch.apply_patch(None, copy.deepcopy(ops))
        return RunLog(*ops, state=state)

    msg = f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
    raise TypeError(msg)

```

[libs/core/langchain_core/tracers/log_stream.py](https://github.com/langchain-ai/langchain/blob/92c7defb0ac54ca2be18fca1bcf89cc88d9356c6/libs/core/langchain_core/tracers/log_stream.py#L137-L155) · [More projects using JSON Patch →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20jsonpatch%20for%20differences%2C%20reconciliation%20and%20patch%20application&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import jsonpatch

source = {"name": "old"}
patch = jsonpatch.make_patch(source, {"name": "new"})
print(patch.patch)

```

From [tutorial.rst](https://python-json-patch.readthedocs.io/en/latest/tutorial.html)

### DeepDiff

[GitHub](https://github.com/qlustered/deepdiff) · [PyPI](https://pypi.org/project/deepdiff) · [Docs](https://zepworks.com/deepdiff/)

Finds deep differences between Python objects and can create structured-data deltas.

- Downloads / mo: 62.8M
- Stars: 2.5K
- Last release: 9.2.1
- License: MIT
- Capabilities: [From the DeepDiff docs](https://zepworks.com/deepdiff/)

**Strengths**

- **Compares nested Python objects.** Report changes inside dictionaries, lists, and custom objects.
- **Can ignore iterable ordering.** Use ignore_order when list position should not determine matching.

**Watch out for**

- **Ignoring order hides duplicate changes.** Enable report_repetition when repeated-item counts must be compared.
- **Custom objects need JSON mappings.** Provide a conversion mapping for types the serializer cannot encode.

```sh
pip install deepdiff
```

**Quickstart**

```python
from deepdiff import DeepDiff

print(DeepDiff({"name": "old"}, {"name": "new"}))

```

From [basics.html](https://zepworks.com/deepdiff/current/diff.html) · [Find projects using DeepDiff →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20deepdiff%20for%20differences%2C%20reconciliation%20and%20patch%20application&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### Levenshtein

[GitHub](https://github.com/rapidfuzz/Levenshtein) · [PyPI](https://pypi.org/project/Levenshtein) · [Docs](https://rapidfuzz.github.io/Levenshtein/)

Computes string edit distances and similarities in a Python extension.

- Downloads / mo: 20.5M
- Stars: 401
- Last release: 0.27.5
- License: GPL-2.0-or-later
- Capabilities: [From the Levenshtein docs](https://rapidfuzz.github.io/Levenshtein/)

```sh
pip install Levenshtein
```

**ai-forever/sage** (169 stars)

[ai-forever/sage](https://github.com/ai-forever/sage) 

```python
def get_levenshtein_mask(source, correct, error2idx):
    mask = [[0] for _ in range(len(correct))]
    changes = Levenshtein.editops(correct, source)
    changes_letters = []
    for change in changes:
        if change[0] == 'delete' or change[0] == 'replace':
            changes_letters.append((change[0], change[1], change[2], correct[change[1]]))
        else:
            changes_letters.append((change[0], change[1], change[2], source[change[2]]))
    swap_changes = []
    i = 0
    while i < len(changes_letters) - 1:
        change_1 = changes_letters[i]
        change_2 = changes_letters[i + 1]
        if change_1[0] == 'insert' and change_2[0] == 'delete' and change_1[3] == change_2[3] and change_2[1] - \
                change_1[1] == 1:
            swap_changes.append(('swap', change_1[1], change_1[2], change_1[3]))
            swap_changes.append(('swap', change_2[1], change_1[2] + 1, change_2[3]))
            i += 2
        else:
            swap_changes.append(change_1)
            i += 1
    if i == len(changes_letters) - 1:
        swap_changes.append(changes_letters[i])

    for change in swap_changes:
        if change[0] == 'delete':
            mask[change[1]][0] = -1
        elif change[0] == 'replace':
            mask[change[1]][0] = error2idx['replace']
        elif change[0] == 'insert':
            mask[change[1] - 1].append(error2idx['add'])
        elif change[0] == 'swap':
            mask[change[1]][0] = error2idx['swap']
    new_mask = []
    for m in mask:
        new_mask.extend(m)

    return new_mask

```

[sage/spelling_correction/training/data_utils.py](https://github.com/ai-forever/sage/blob/b535e48dea44279a31356eee61fdb7309d9bd8fb/sage/spelling_correction/training/data_utils.py#L6-L44) · [More projects using Levenshtein →](https://dashboard.exa.ai/playground/search?q=Levenshtein%20GitHub%20projects)

**Quickstart**

```python
from Levenshtein import editops

print(editops("spam", "park"))

```

From [levenshtein.html](https://rapidfuzz.github.io/Levenshtein/levenshtein.html)

### jsondiff

[GitHub](https://github.com/xlwings/jsondiff) · [PyPI](https://pypi.org/project/jsondiff)

Diffs JSON and JSON-like structures in Python.

- Downloads / mo: 7.1M
- Stars: 751
- Last release: 2.2.1
- License: MIT
- Capabilities: [From the jsondiff docs](https://github.com/xlwings/jsondiff)

```sh
pip install jsondiff
```

**meta/openr** (941 stars)

[meta/openr](https://github.com/meta/openr) 

```python
async def _run(self, client: OpenrCtrlCppClient.Async, file: str, *args, **kwargs):
    running_conf = await client.getRunningConfig()

    try:
        file_conf = await client.dryrunConfig(file)
    except OpenrError as ex:
        click.echo(click.style(f"FAILED: {ex}", fg="red"))
        return

    res = jsondiff.diff(running_conf, file_conf, load=True, syntax="explicit")
    if res:
        click.echo(click.style("DIFF FOUND!", fg="red"))
        print(f"== diff(running_conf, {file}) ==")
        print(res)
    else:
        click.echo(click.style("SAME", fg="green"))

```

[openr/py/openr/cli/commands/config.py](https://github.com/meta/openr/blob/c2a4bbba958d9d5892bd8d6d3e9cd712a0abe000/openr/py/openr/cli/commands/config.py#L48-L63) · [More projects using jsondiff →](https://dashboard.exa.ai/playground/search?q=jsondiff%20GitHub%20projects)

**Quickstart**

```python
import jsondiff

print(jsondiff.diff({"name": "old"}, {"name": "new"}))

```

From [__init__.py](https://github.com/xlwings/jsondiff/blob/master/jsondiff/__init__.py)

### Diff Match Patch

[GitHub](https://github.com/diff-match-patch-python/diff-match-patch) · [PyPI](https://pypi.org/project/diff-match-patch) · [Docs](https://pypi.org/project/diff-match-patch/)

Repackages the Google Diff Match and Patch libraries.

- Downloads / mo: 6.8M
- Stars: 59
- Last release: 20241021
- License: Apache-2.0
- Capabilities: [From the Diff Match Patch docs](https://pypi.org/project/diff-match-patch/)

```sh
pip install diff-match-patch
```

**Aider-AI/aider** (50.2K stars)

[Aider-AI/aider](https://github.com/Aider-AI/aider) 

```python
def map_patches(texts, patches, debug):
    search_text, replace_text, original_text = texts

    dmp = diff_match_patch()
    dmp.Diff_Timeout = 5

    diff_s_o = dmp.diff_main(search_text, original_text)
    # diff_r_s = dmp.diff_main(replace_text, search_text)

    # dmp.diff_cleanupSemantic(diff_s_o)
    # dmp.diff_cleanupEfficiency(diff_s_o)

    if debug:
        html = dmp.diff_prettyHtml(diff_s_o)
        Path("tmp.html").write_text(html)

        dump(len(search_text))
        dump(len(original_text))

    for patch in patches:
        start1 = patch.start1
        start2 = patch.start2

        patch.start1 = dmp.diff_xIndex(diff_s_o, start1)
        patch.start2 = dmp.diff_xIndex(diff_s_o, start2)

        if debug:
            print()
            print(start1, repr(search_text[start1 : start1 + 50]))
            print(patch.start1, repr(original_text[patch.start1 : patch.start1 + 50]))
            print(patch.diffs)
            print()

    return patches

```

[aider/coders/search_replace.py](https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/coders/search_replace.py#L193-L226) · [More projects using Diff Match Patch →](https://dashboard.exa.ai/playground/search?q=diff-match-patch%20GitHub%20projects)

**Quickstart**

```python
from diff_match_patch import diff_match_patch

dmp = diff_match_patch()
print(dmp.diff_main("spam", "park"))

```

From [diff_match_patch.py](https://github.com/diff-match-patch-python/diff-match-patch/blob/main/diff_match_patch/diff_match_patch.py)

### dictdiffer

[GitHub](https://github.com/inveniosoftware/dictdiffer) · [PyPI](https://pypi.org/project/dictdiffer) · [Docs](https://dictdiffer.rtfd.io/)

Compares dictionary, list, and set structures and applies their change operations.

- Downloads / mo: 5.8M
- Stars: 849
- Last release: 0.10.0
- License: MIT
- Capabilities: [From the dictdiffer docs](https://dictdiffer.rtfd.io/)

**Strengths**

- **Diffs and patches dictionary structures.** Apply returned change operations with patch or reverse them with revert.
- **Supports numeric comparison tolerance.** Treat close numeric values as equal using a tolerance.

**Watch out for**

- **Patching copies the destination.** Set in_place to modify the original destination instead.

```sh
pip install dictdiffer
```

**tortoise/aerich** (1.1K stars)

[tortoise/aerich](https://github.com/tortoise/aerich) 

```python
def get_dict_diff_by_key(
    old_fields: list[dict],
    new_fields: list[dict],
    key: str = "through",
    second_key: str = "forward_key",
) -> Generator[tuple[str, Any, Any]]:
    """
    Compare two list by key instead of by index

    :param old_fields: previous field info list
    :param new_fields: current field info list
    :param key: if two dicts have the same value of this key, action is change; otherwise, is remove/add
    :param second_key: if multi fields with same value of key, use `(field[key], field[second_key])` as ident
    :return: similar to dictdiffer.diff

    Example::

        >>> old = [{'through': 'a'}, {'through': 'b'}, {'through': 'c'}]
        >>> new = [{'through': 'a'}, {'through': 'c'}]  # remove the second element
        >>> list(diff(old, new))
        [('change', [1, 'through'], ('b', 'c')),
         ('remove', '', [(2, {'through': 'c'})])]
        >>> list(get_dict_diff_by_key(old, new))
        [('remove', '', [(0, {'through': 'b'})])]

    """
    length_old, length_new = len(old_fields), len(new_fields)
    if length_old == 0 or length_new == 0:
        yield from diff(old_fields, new_fields)
    elif length_old == length_new == 1:
        yield from _get_field_diffs(old_fields[0], new_fields[0])
    else:
        should_use_second_key = len({i[key] for i in old_fields}) < length_old or (
            len({i[key] for i in new_fields}) < length_new
        )
        value_index: dict[str | tuple[str, str], int] = (
            {(f[key], f[second_key]): i for i, f in enumerate(new_fields)}
            if should_use_second_key
            else {f[key]: i for i, f in enumerate(new_fields)}
        )
        additions = set(range(length_new))
        for field in old_fields:
            value = (field[key], field[second_key]) if should_use_second_key else field[key]
            if (index := value_index.get(value)) is not None:
                additions.remove(index)
                yield from _get_field_diffs(field, new_fields[index])  # change
            else:
                yield from diff([field], [])  # remove
        if additions:
            for index in sorted(additions):
                yield from diff([], [new_fields[index]])  # add

```

[aerich/utils.py](https://github.com/tortoise/aerich/blob/a4b8186d77c380b67d443bf3b84732b810b3d2bb/aerich/utils.py#L294-L344) · [More projects using dictdiffer →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20dictdiffer%20for%20differences%2C%20reconciliation%20and%20patch%20application&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from dictdiffer import diff

print(list(diff({"name": "old"}, {"name": "new"})))

```

From [index.rst](https://dictdiffer.readthedocs.io/en/stable/)

### xmldiff

[GitHub](https://github.com/Shoobx/xmldiff) · [PyPI](https://pypi.org/project/xmldiff)

Creates diffs of XML files.

- Downloads / mo: 345.8K
- Stars: 231
- Last release: 3.0
- License: MIT
- Capabilities: [From the xmldiff docs](https://github.com/Shoobx/xmldiff)

```sh
pip install xmldiff
```

**AshleyYakeley/NixVirt** (408 stars)

[AshleyYakeley/NixVirt](https://github.com/AshleyYakeley/NixVirt) 

```python
def define(self):
    if self.specDefXML is not None:
        if self.subject is not None:
            oldDefETree = self.subject.descriptionETree()
            foundName = oldDefETree.find("name").text
            if foundName != self.specName:
                self.subject.undefine()
            self.oc._cleanDefETree(self.specDefXML,oldDefETree)
            self.vreport("redefine")
            newvobject = self.oc._fromXML(self.specDefXML)
            match self.restart:
                case True:
                    self.vreport("always restart")
                    self.subject._deactivate()
                case False:
                    self.vreport("never restart")
                case None:
                    self.vreport("detect restart")
                    newDefETree = newvobject.descriptionETree()
                    self.oc._cleanDefETree(self.specDefXML,newDefETree)
                    diff = xmldiff.main.diff_trees(oldDefETree,newDefETree)
                    if len(diff) > 0:
                        if self.oc.session.verbose:
                            difftext = xmldiff.main.diff_trees(oldDefETree,newDefETree,formatter=xmldiff.formatting.DiffFormatter())
                            self.vreport("changed:\n" + difftext)
                        self.subject._deactivate()
                    else:
                        self.vreport("unchanged")
            self.subject = newvobject
        else:
            self.vreport("define new")
            self.subject = self.oc._fromXML(self.specDefXML)

```

[tool/nixvirt.py](https://github.com/AshleyYakeley/NixVirt/blob/b9489f0e4b1cef1d5fe5dcc48f705c1cdfc9e7a8/tool/nixvirt.py#L371-L402) · [More projects using xmldiff →](https://dashboard.exa.ai/playground/search?q=xmldiff%20GitHub%20projects)

**Quickstart**

```python
from xmldiff import main

print(main.diff_texts("<root/>", "<root><item/></root>"))

```

From [api.html](https://xmldiff.readthedocs.io/en/stable/api.html)

## FAQ

### Which Python diff library should I use?

[DeepDiff](#deepdiff) suits nested Python objects and JSON-like data. [JSON Patch](#jsonpatch) suits changes that other systems must apply as standard JSON Patch operations. [Diff Match Patch](#diff-match-patch) suits plain text with patches that tolerate shifted context.

### What is DeepDiff?

[DeepDiff](#deepdiff) finds deep differences between Python objects and reports them by path. Its Delta interface stores those changes and replays them against the original data.

### How do I diff two strings in Python?

The built-in difflib module compares two sequences of lines or characters. [Diff Match Patch](#diff-match-patch) adds patch objects that apply to text with surrounding context, and [Levenshtein](#levenshtein) computes edit distances and edit operations.

### What is xmldiff?

[xmldiff](#xmldiff) compares parsed XML trees and returns semantic edit actions. Those actions apply to the original XML as a patch script.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python diff libraries difflib DeepDiff Dictdiffer jsonpatch code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
