Text diff
Compare two blocks of text line by line and see additions and deletions highlighted. Nothing leaves your browser.
line one− line two+ line 2line three+ line four
What this text diff does
Paste an original and a changed version of any text and the tool shows a unified, line-by-line comparison: unchanged lines in plain text, removed lines on a red background with a minus sign, added lines on a green background with a plus sign, and a count of each at the top. It is meant for the everyday case of “what exactly changed here?” when you have two copies of a config, a response body, a paragraph of documentation or a generated file and no version control between them.
How to use it
- Paste the older version into Original (left) and the newer version into Changed (right).
- The diff recomputes on every keystroke; there is no submit button.
- Read the badges: +N is the number of added lines, −N the number of removed lines.
- Scroll the output. Each line keeps its original whitespace, and long lines wrap rather than overflow, so the view stays readable on narrow screens.
How the diff is computed
The tool uses the classic longest common subsequence (LCS) approach. It splits both inputs on newlines, builds a table of LCS lengths for every pair of positions, and walks the table from the start to produce the shortest edit script that turns the original into the changed text. That script contains only three operations: keep a line, delete a line, insert a line. Moves are not detected, so a block that was cut from the top and pasted at the bottom appears as a deletion plus an insertion.
The cost is O(n × m) in both time and memory, where n and m are the two line counts. That is instant for typical snippets, configs and log excerpts, and noticeably slower above roughly 10,000 lines per side.
Line vs word vs character diffs
| Granularity | Best for | Trade-off |
|---|---|---|
| Line (this tool) | Code, config, logs, lists, CSV | A one-character typo shows as a whole line replaced. Fast and easy to read. |
| Word | Prose, documentation, marketing copy | Highlights exactly which words changed inside a sentence; noisier for code. |
| Character | Short strings, identifiers, hashes | Very precise but produces unreadable output for anything longer than a sentence. |
Git, GitHub and most editors default to line diffs for the same reason this tool does: lines are the natural unit of change in source code, and a line diff maps directly onto what a code review discusses.
Reading a unified diff
If you are used to git diff output, the output here is the same idea without hunk headers. Lines prefixed with − exist only in the original; lines prefixed with + exist only in the changed text; lines with a space prefix are shared context. A modified line always appears as a −/+ pair, usually adjacent. When a − line and a + line look identical, the difference is invisible whitespace, typically a trailing space, a tab versus spaces, or Windows \r\n line endings on one side only.
Tips for cleaner diffs
- Normalize before comparing. Pretty-print JSON on both sides with the JSON formatter so key order and indentation match. Sort lines in lists if order does not matter.
- Strip volatile fields. Timestamps, request IDs and generated hashes will always differ; remove them before pasting if you only care about structural changes.
- Compare one concern at a time. A diff of a 500-line file where someone also reformatted everything is useless. Run the formatter first, commit that, then diff the real change.
- Use it for AI edits. If an assistant rewrote a file, paste the before and after here to review every line it touched before accepting.
Related tools and snippets
- JSON formatter to pretty-print both sides first so the diff shows only real changes.
- Regex tester to find and replace patterns, then diff the result against the original.
- Word and character counter to measure how much text was added or removed.
- Case converter when the only difference between two identifiers is their casing.
- Hash generator to confirm two large files are byte-identical without diffing them.
FAQ
Is this a line diff, a word diff or a character diff?
It is line-based. The tool finds the longest common subsequence of whole lines, keeps those as context, and marks everything else as added or removed. A line with a single changed character shows as one removed line plus one added line.
Does it ignore whitespace or case?
No. Lines are compared exactly, so trailing spaces, tabs versus spaces and capitalization all count as differences. Normalize your inputs first if you want to ignore those.
Can I compare JSON, YAML or code?
Yes, anything that is plain text. For JSON, run both sides through the JSON formatter first so keys are consistently indented and ordered the same way, otherwise formatting noise hides the real change.
What do the plus and minus badges mean?
The green badge counts lines that exist only in the Changed text; the red badge counts lines that exist only in the Original. Unchanged lines are not counted.
How large can the inputs be?
The algorithm builds a table of lines-in-A times lines-in-B, so two 2,000-line files are fine, but two 50,000-line logs will be slow. For very large files use git diff or a desktop tool.
Is my text uploaded?
No. The diff runs entirely in your browser, which makes it safe for config files, API responses and anything else you would not paste into a third-party service.