Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

diff-match-patch

> 编程语言
Open source

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.

8.1K stars0 likes2 views
WebsiteGitHub

About

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.

The Diff Match and Patch libraries offer robust algorithms to perform the operations required for synchronizing plain text.

  1. Diff:
    • Compare two blocks of plain text and efficiently return a list of differences.
    • Diff Demo
  2. Match:
    • Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
    • Match Demo
  3. Patch:
    • Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.
    • Patch Demo

Originally built in 2006 to power Google Docs, this library is now available in C++, C#, Dart, Java, JavaScript, Lua, Objective C, and Python.

Reference

  • API - Common API across all languages.
  • Line or Word Diffs - Less detailed diffs.
  • Plain Text vs. Structured Content - How to deal with data like XML.
  • Unidiff - The patch serialization format.
  • Support - Newsgroup for developers.

Languages

Although each language port of Diff Match Patch uses the same API, there are some language-specific notes.

  • C++
  • C#
  • Dart
  • Java
  • JavaScript
  • Lua
  • Objective-C
  • Python

A standardized speed test tracks the relative performance of diffs in each language.

Algorithms

This library implements Myer's diff algorithm which is generally considered to be the best general-purpose diff. A layer of pre-diff speedups and post-diff cleanups surround the diff algorithm, improving both performance and output quality.

This library also implements a Bitap matching algorithm at the heart of a flexible matching and patching strategy.

Issues· 97 open

View all issuesOpen on GitHub
  • #114

    could generate something like git diff unified format by diff-match-patch?

    Updated Jun 13, 2024
  • #164

    Registered Successfully

    Updated May 29, 2024
  • #157

    patch_fromText and lines breaks issue in Python

    Updated May 28, 2024
  • #39

    JavaScript: Diff is not iterable

    Updated May 2, 2024
  • #54

    Javascript line diff breaks beyond 65K lines

    Updated Feb 12, 2024
  • #155

    Trying to use this in .NET 481

    Updated Feb 1, 2024
  • #143

    Project abandoned / dead / maintained?

    Updated Jan 31, 2024
  • #149

    Patch margin index splits Unicode surrogate pairs unexpectedly

    Updated Jan 4, 2024
  • #101

    Lua Script is not compatible with LUA5.4

    Updated Nov 20, 2023
  • #147

    Fails to add newline after patch, fails to remove last character that needs to be removed

    Updated Oct 25, 2023

> Tags

Pythondiffdifferencematchpatch

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言