Text Compare (Diff) Widget

Add a text comparison tool to your editing or developer pages. Readers paste an original and a changed version and see exactly which lines or words were added and removed, with a similarity figure.

SEO & Content Tool Runs in your browser Free · no ads

Customize your widget

Theme
Auto follows the visitor's light/dark setting.
Style
Attribution on your page
The widget is free; a visible credit is how you can say thanks. It is one plain line, shown in the code below, linking to the tool with rel="nofollow". Switch it off here or delete the line - the widget works the same either way.
More options
Starting values
Leave blank to use the widget's defaults. Visitors can still change every value.

Live preview

Exactly what your visitors will see

Under the widget on your page: Text Compare (Diff) by A2Z Tools

Embed code

<div data-a2z-widget="text-compare" data-height="850"></div>
<p class="a2z-attribution" style="margin:6px 0 0;font:12px/1.4 system-ui,sans-serif;opacity:.8">Text Compare (Diff) by <a href="https://a2z.tools/compare-text-string" target="_blank" rel="nofollow noopener">A2Z Tools</a></p>
<script async src="https://a2z.tools/embed.js"></script>

Recommended. A small script (what it does) sizes the widget to fit its content, loads it lazily and keeps it isolated in its own frame. Works in WordPress (Custom HTML block), Squarespace, Webflow, Shopify, Blogger, React / Next.js and plain HTML - anywhere a <script> tag is allowed.

Works with

Advertisement

How it works

The widget uses Eugene Myers' O(ND) difference algorithm, the approach behind diff and git, which finds the smallest set of additions and removals that turns the original into the changed text. It can compare whole lines or individual words, optionally ignoring letter case or extra spaces. Removed lines are marked with -, added lines with +, and long unchanged stretches collapse to a single line so changes stand out; in word mode removed and added words are struck through and underlined. Changes are never shown by colour alone. To keep the page responsive, each text is limited to 10,000 lines or 20,000 words and 2,000 differences.

Method

  • Myers (1986) shortest edit script over lines or word tokens, after trimming the common prefix and suffix
  • Similarity = 2 x unchanged / (tokens in A + tokens in B) x 100
  • Options: ignore case, ignore extra whitespace (compare only)
  • Limits: 500,000 characters, 10,000 lines or 20,000 words per text, 2,000 differences

Limitations

  • Moved blocks are shown as a removal plus an addition, not detected as a move.
  • No character-level highlighting inside a changed word, and no three-way merge.
  • It compares plain text; Word, PDF or HTML formatting changes are invisible unless they change the visible characters.
  • The minimal edit script is not always the most readable one; git's patience and histogram options can group code changes differently.

Where publishers use it

  • Editors and translators reviewing revisions of an article
  • Legal and policy pages showing what changed between versions
  • Developer tutorials explaining how diff works
  • Teachers checking a rewritten paragraph against the original

Questions

Is this the same as git diff?

It uses the same core algorithm (Myers), so the changes found are equivalent, though git adds heuristics for code.

When should I compare by words?

For prose. Line mode is better for code, lists and configuration files; word mode shows small edits inside a sentence.

Why is there a size limit?

The work grows with the number of differences, so very large or completely different texts could freeze the page. Compare sections instead.

Are my texts stored?

No. The comparison runs entirely in the browser.

Sources

  1. Myers, E. W. (1986). An O(ND) difference algorithm and its variations. Algorithmica 1, 251-266 - Springer . Shortest edit script used for both line and word modes

Cite or recommend this tool

If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.

A2Z Tools Text Compare (Diff)
https://a2z.tools/compare-text-string
  • Case Converter

    SEO & Content Converter

    Title Case, Sentence case, UPPER, lower, camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE.

    Get code
  • Word Counter

    SEO & Content Tool

    Words, characters, sentences, paragraphs, reading time and social-media character limits.

    Get code
  • Regex Tester

    Developer Tools Tool

    Test a JavaScript regular expression: highlighted matches, capture groups and a replace preview.

    Get code
  • JSON Formatter & Validator

    Developer Tools Tool

    Pretty-print, minify or validate JSON, with the line and column of the first syntax error.

    Get code
  • SERP Snippet Preview

    SEO & Content Tool

    Preview a title, URL and meta description as a Google-style result, with pixel-width estimates.

    Get code
  • Social Card Preview

    SEO & Content Tool

    Preview Facebook, LinkedIn and X link cards and generate the Open Graph meta tags.

    Get code

Preview

Advertisement