# google/diff-match-patch

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/google-diff-match-patch).**

8,065 stars · 1,178 forks · Python · apache-2.0 · archived

## Links

- GitHub: https://github.com/google/diff-match-patch
- awesome-repositories: https://awesome-repositories.com/repository/google-diff-match-patch.md

## Topics

`diff` `difference` `match` `patch` `text-processing`

## Description

This is a text diffing and patching library used for computing differences between text blocks, calculating edit distances, and applying patches to synchronize document versions. It includes a fuzzy text matching engine to locate strings by balancing accuracy with location, and a Levenshtein distance calculator to measure the number of character insertions, deletions, and substitutions between two strings.

The library features a semantic diff optimizer that refines raw text differences to align with human-readable word and phrase boundaries. It provides utilities for generating and parsing serialized patches, allowing structural differences to be stored or transmitted and then applied to documents using a best-effort strategy to handle source offsets.

The project covers a broad range of text manipulation capabilities, including text comparison, difference computation, and pattern matching. These tools enable the measurement of edit distance and the synchronization of plain text versions through the application of optimized difference sets.

## Tags

### Software Engineering & Architecture

- [Text Diffing and Patching Libraries](https://awesome-repositories.com/f/software-engineering-architecture/text-diffing-and-patching-libraries.md) — A comprehensive library for computing differences between text blocks and applying patches to synchronize document versions.
- [Text Patching](https://awesome-repositories.com/f/software-engineering-architecture/text-patching.md) — Provides a comprehensive system for synchronizing document versions through the application of serialized patches. ([source](https://github.com/google/diff-match-patch/wiki/Plain-Text-vs.-Structured-Content))
- [Patch Generators](https://awesome-repositories.com/f/software-engineering-architecture/code-patching-engines/patch-generators.md) — Encodes structural text differences into a standardized string format for storage and transmission.
- [Patch Application](https://awesome-repositories.com/f/software-engineering-architecture/code-patching-engines/patch-generators/patch-application.md) — Provides utilities to apply patches to text blocks using a best-effort strategy to handle shifts in the source content.
- [Patch Parsing](https://awesome-repositories.com/f/software-engineering-architecture/code-patching-engines/patch-generators/patch-parsing.md) — Converts textual diff formats back into machine-readable patches to apply changes to documents. ([source](https://github.com/google/diff-match-patch/wiki/Unidiff))
- [Semantic Diff Optimizers](https://awesome-repositories.com/f/software-engineering-architecture/semantic-diff-optimizers.md) — Routines that refine raw text differences to align with human-readable word and phrase boundaries.
- [Difference Set Optimization](https://awesome-repositories.com/f/software-engineering-architecture/string-matching-algorithms/string-comparisons/difference-calculations/difference-set-optimization.md) — Optimizes difference sets by removing coincidental matches to improve human readability and machine efficiency. ([source](https://github.com/google/diff-match-patch/wiki/API))

### Development Tools & Productivity

- [Multi-File Patch Synchronization](https://awesome-repositories.com/f/development-tools-productivity/multi-file-patch-synchronization.md) — Synchronizes documents by applying a series of changes while accounting for shifts in the source text.
- [Text File Comparison](https://awesome-repositories.com/f/development-tools-productivity/text-file-comparison.md) — Identifies specific additions and deletions required to transform one block of plain text into another.
- [Text Difference Computation](https://awesome-repositories.com/f/development-tools-productivity/text-object-selection/text-block-movement/text-difference-computation.md) — Determines exactly which characters or words were added, removed, or modified between two versions of text. ([source](https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs))
- [Semantic Boundary Alignment](https://awesome-repositories.com/f/development-tools-productivity/version-control-repository-tools/version-control-managers/git-utilities/git-cleanup-utilities/style-based-diff-cleanup/semantic-boundary-alignment.md) — Post-processes raw character differences to group changes into logical word and phrase boundaries for humans.

### Programming Languages & Runtimes

- [Human-Readable Diffing](https://awesome-repositories.com/f/programming-languages-runtimes/human-readable-diffing.md) — Refines raw text differences to align with word boundaries and phrase blocks for better human readability.
- [Edit Distance Calculators](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/string-utilities/string-manipulators/edit-distance-calculators.md) — Calculates the Levenshtein distance between two strings based on insertions, deletions, and substitutions.
- [Bit-Parallel Implementations](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/string-utilities/string-manipulators/edit-distance-calculators/bit-parallel-implementations.md) — Implements a bit-vector approach to significantly accelerate Levenshtein distance calculations across text strings.

### Scientific & Mathematical Computing

- [Diff Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/diff-algorithms.md) — Implements the Myers diff algorithm to compute the shortest edit script between two text blocks.

### Data & Databases

- [Fuzzy Matching](https://awesome-repositories.com/f/data-databases/fuzzy-matching.md) — Provides a search utility that balances accuracy and location to find the best fuzzy match for a string.
- [Location-Weighted Matching](https://awesome-repositories.com/f/data-databases/fuzzy-matching/location-weighted-matching.md) — Locates text patterns by balancing character accuracy with proximity to a target index for more precise matching.
- [Text Pattern Matching](https://awesome-repositories.com/f/data-databases/text-pattern-matching.md) — Locates exact or fuzzy matches of specific text strings within larger bodies of plain text. ([source](https://github.com/google/diff-match-patch/wiki/Plain-Text-vs.-Structured-Content))

### User Interface & Experience

- [Semantic Grouping](https://awesome-repositories.com/f/user-interface-experience/diff-visualizations/semantic-grouping.md) — Groups fragmented text changes into human-readable blocks to make raw differences more intuitive. ([source](https://github.com/google/diff-match-patch/wiki/Language:-C%23))
- [Semantic Refinement](https://awesome-repositories.com/f/user-interface-experience/diff-visualizations/semantic-refinement.md) — Refines raw text differences to ensure they align with natural human-readable word and phrase boundaries. ([source](https://github.com/google/diff-match-patch/wiki/Language:-Java))
