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.
Live preview
Exactly what your visitors will seeUnder the widget on your page: Powered by A2Z Tools
Embed code
<iframe src="https://a2z.tools/embed/w/text-compare" title="Text Compare (Diff) by A2Z Tools" width="100%" height="850" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>
A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.
<div data-a2z-widget="text-compare" data-height="850"></div> <script async src="https://a2z.tools/embed.js"></script>
Adds a small script (what it does) that sizes the widget to fit its content, loads it lazily and keeps it isolated from your page's CSS.
Works with
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
- 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
<a href="https://a2z.tools/compare-text-string">A2Z Tools Text Compare (Diff)</a>
[A2Z Tools Text Compare (Diff)](https://a2z.tools/compare-text-string)
Text Compare (Diff) by A2Z Tools - https://a2z.tools/compare-text-string
Related widgets
-
Title Case, Sentence case, UPPER, lower, camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE.
-
Words, characters, sentences, paragraphs, reading time and social-media character limits.
-
Test a JavaScript regular expression: highlighted matches, capture groups and a replace preview.
-
Pretty-print, minify or validate JSON, with the line and column of the first syntax error.
-
Preview a title, URL and meta description as a Google-style result, with pixel-width estimates.
-
Preview Facebook, LinkedIn and X link cards and generate the Open Graph meta tags.