Text Diff Generator
A diff is only useful if it is right, and the way to know is to apply it. This compares two texts line by line, finds the longest run of lines they have in common, and shows everything else as an addition or a removal — then replays that edit script over the original and checks the result matches the second text exactly before showing you anything.
What this generator does
Finds the longest sequence of lines the two texts have in common, marks those as unchanged, and expresses everything else as an insertion or removal. The edit script is then applied to the original and compared against the second text before display.
How to use this tool
- Paste the original text on the left.
- Paste the changed version on the right.
- Run, and read the additions in green and removals in amber.
- Copy the result as a plain-text diff if you need it elsewhere.
Understanding the controls
- Original text
- The version being compared from. Comparison is line by line, so a change anywhere in a line marks the whole line.
- Changed text
- The version being compared to. Blank lines count as lines, which is usually what you want when comparing configuration or code.
Common use cases
- Comparing two drafts of a document without a version control tool
- Checking exactly what changed between two configuration files
- Spotting an unintended edit in a block of pasted text
- Teaching how a diff works using the longest common subsequence
- Producing a readable change summary to paste into a message
How this generator works
The unchanged lines are a longest common subsequence of the two texts, computed with the standard dynamic-programming table. That is what makes the diff minimal rather than merely correct: no smaller set of changes exists. The script is then verified by replaying it — every kept line must match the original at that position, every removed line must actually be there, and the result must equal the second text exactly. A diff that fails any of those is reported rather than shown.
Randomness and fairness
Nothing here is random. The same two texts always produce the same diff.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Comparison is by whole lines, so a one-character change marks the entire line as replaced.
- A block of text that moved shows as a removal and an insertion — a subsequence diff has no concept of a move.
- There is no word-level or character-level view within a changed line.
- Very large texts will be slow, since the underlying table grows with the product of the two line counts.
Privacy and your data
Both texts are compared entirely in your browser. Nothing you paste is uploaded, stored, or included in analytics — only the fact that the tool ran.
Related generators
- Edit Distance CalculatorThe fewest single-character edits that turn one word into another, listed step by step and proved by replaying them.
- Text Wrapping and Raggedness GeneratorWraps text to a fixed width greedily, scores how ragged the right edge is, and checks every word survived in order.
- Run-Length Encoding GeneratorEncodes text as runs of repeated characters, decodes it back to prove it is exact, and says plainly when the result is longer.
- JSON Sample GeneratorGenerate a small sample JSON object with randomised placeholder values, for API mockups.