oktools

Text Diff & Compare

Compare two blocks of plain text and see exactly what changed — line by line, and word by word inside an edited line. A free online diff checker: paste the texts in, or compare two text files online by dropping one on either side. Everything is compared in your browser, so nothing you paste is uploaded.

6 lines · 204 characters
6 lines · 228 characters

Differences

43%Similarity
+1Added
−1Removed
~2Modified
OriginalChanged
1# Release notes1# Release notes
changed2The server starts on port 8080 by default.2The server starts on port 3000 by default.
3Set LOG_LEVEL to debug for verbose output.3Set LOG_LEVEL to debug for verbose output.
changed4Sessions expire after 30 minutes.4Sessions expire after 60 minutes of inactivity.
removed5Caching is disabled in development.
6Run npm start to launch the app.5Run npm start to launch the app.
added6Run npm test to check everything still works.

How it works

Each side is split into lines on LF, CRLF or CR line endings, and a single trailing newline is not an extra empty line. Every line gets a comparison key that reflects the options — spaces and tabs collapsed and trimmed, letters lower-cased, blank lines dropped — while the text shown stays as typed. Matching lines at the top and bottom are settled first. What remains is split on anchor lines, ones that occur exactly once on each side, in an order both sides agree on; the stretches between anchors are diffed recursively, with an exact longest-common-subsequence table up to four million cells and a wholesale replacement beyond that.

The edit script becomes rows. A run of removed lines followed by added ones is the usual shape of an edited passage, so those are paired off in order into modified rows, which keeps the two columns level; any surplus becomes plain removals or additions. A modified row is then compared word by word: the line is tokenised into words, runs of whitespace and single punctuation marks, the token lists are aligned the same way, and the tokens that differ are coloured, with the space between two changed words absorbed into one highlight. When the shared text is under a quarter of the longer line, or either line has over 400 tokens, the whole line is coloured instead.

The stats count rows: added, removed, modified and unchanged, with similarity the share of rows that came through unchanged. Side by side draws the rows in one grid, so the columns are already in step and one scrollbar moves both; Inline shows a modified row as its two halves, what went out and then what came in; Changes only keeps the rows that differ, each with its line number on each side. Rows are drawn 400 at a time. Copy as patch and Download .patch write the same rows out as a unified diff with three lines of context, removals before additions within a hunk and headers such as @@ -1,4 +1,4 @@.

Examples

See what changed in a release note

The stats bar reads 20% similarity, +1, −1 and ~2: one of five rows is unchanged. Inside the first two rows only 8080, 3000, 30, 60 and “of inactivity” are highlighted; the caching line has no counterpart to pair with, so it is a removal rather than an edit.

Original and changed
Original:
The server starts on port 8080 by default.
Sessions expire after 30 minutes.
Caching is disabled in development.
Run npm start to launch the app.

Changed:
The server starts on port 3000 by default.
Sessions expire after 60 minutes of inactivity.
Run npm start to launch the app.
Run npm test to check everything still works.
Changes only
~ Modified  line 1  The server starts on port 8080 by default. → The server starts on port 3000 by default.
~ Modified  line 2  Sessions expire after 30 minutes. → Sessions expire after 60 minutes of inactivity.
− Removed   line 3  Caching is disabled in development.
+ Added     line 4  Run npm test to check everything still works.

Export the comparison as a patch

The hunk header says that the original’s lines 1 to 3 became lines 1 to 2. The unchanged LOG_LEVEL line is kept as context so that patch and git apply can place the change; Download .patch saves the same text as changes.patch.

Original and changed
Original:
PORT=8080
LOG_LEVEL=info
CACHE=on

Changed:
PORT=3000
LOG_LEVEL=info
Copy as patch
--- original
+++ modified
@@ -1,3 +1,2 @@
-PORT=8080
+PORT=3000
 LOG_LEVEL=info
-CACHE=on

Ignore a reindent

The second line is indented with two spaces on one side and a tab on the other. With the options off it is one modified row; with Ignore whitespace on, the two keys compare equal and the texts are reported identical, though the tab is still shown.

Original and changed
Original:
function greet(name) {
  return "Hi " + name;
}

Changed:
function greet(name) {
	return "Hi " + name;
}
Result
Ignore whitespace off:  67% similarity, ~1 modified
Ignore whitespace on:   100% similarity — The two texts are identical

Follow a line to its new number

A modified row reports the number on each side when they differ, because removing beta moved everything after it up by one. Tick Ignore case and the second row disappears, leaving one removal and 75% similarity.

Original and changed
Original:
alpha
beta
gamma
delta

Changed:
alpha
gamma
DELTA
Changes only
− Removed   line 2      beta
~ Modified  line 4 → 3  delta → DELTA

Supported formats

  • Plain text of any kindSource code, configuration, logs, CSV, Markdown or prose, with LF, CRLF or CR line endings, mixed between the two sides or within one.
  • Files, dropped or openedDrop a file onto either panel or use Open file. It is decoded as UTF-8 in the browser and never uploaded; a file over 2 MB is refused with a note asking for the part you want to compare.
  • Three things not to countIgnore case compares letters without regard to capitalisation; Ignore whitespace treats any run of spaces or tabs as one space and drops leading and trailing runs; Ignore blank lines leaves empty lines out. All three change the comparison only — the text is displayed and exported exactly as typed.
  • Unified diff outHeaders --- original and +++ modified, hunks with three lines of context and @@ -start,count +start,count @@ markers, content created from nothing written as @@ -0,0 +1,n @@. Copied to the clipboard or saved as changes.patch.

Use cases

  • Compare two configuration filesAn .env, nginx.conf or YAML file from two servers or two branches: Changes only lists each line that differs with its number, and Ignore whitespace keeps a reindented block from counting.
  • Review a revised documentPaste two versions of a contract clause, a policy or a release note and read the word-level highlights in the edited lines instead of hunting for the change by eye.
  • Make a patch without a repositoryTwo copies of a file that were never under version control become a unified diff with Copy as patch, ready for a ticket, a code review or patch on the other machine.
  • Confirm a formatter changed nothing but whitespaceCompare the file before and after a reformat with Ignore whitespace on. Anything other than 100% similarity is a line the formatter really did alter.

Limitations

  • No move detectionA block cut from one place and pasted in another is a removal plus an addition, not a move, because the diff only ever adds and removes lines.
  • Lines are the unitA paragraph rewrapped to a different width is compared line by line, and lines that share under a quarter of their text are coloured whole rather than word by word. Unwrap prose onto one line per paragraph first for a readable result.
  • Two plain texts onlyThere is no three-way merge, no directory comparison and no reading of .docx, .pdf or other binary formats. Extract the text first; for two JSON documents, JSON Diff & Compare ignores formatting and key order.
  • Files are read as UTF-8A Latin-1 or Windows-1252 file shows replacement characters where accented letters were. Convert it, or paste the text, before comparing.
  • The patch names no filesIts headers are original and modified, so edit them to the real paths before git apply, or feed it to patch with the target named on the command line: patch config.yml < changes.patch.

Frequently asked questions

How do I compare two texts?

Paste the original on the left and the changed version on the right, or drop a file into either side. The comparison runs as you type: added lines are green, removed lines are red and edited lines are amber, with the words that actually changed picked out inside them.

What is the difference between the three views?

Side by side puts the two versions in adjacent columns, already lined up. Inline stacks them into one unified list, the way git shows a diff. Changes only drops every unchanged line, which is the fastest way to answer "what actually changed" in a long file.

Can I ignore indentation or capitalisation?

Yes. Ignore whitespace treats any run of spaces or tabs as a single space, so a reindented block stops counting as a change. Ignore case compares letters without regard to capitalisation, and ignore blank lines leaves empty lines out of the comparison. The word highlighting follows the same rules, so a word that differs only in case is not painted as a change. The text is always displayed exactly as you typed it.

Can I export the result as a patch?

Yes, two ways. Copy as patch puts the comparison on your clipboard as a unified diff, with three lines of context around each change — the format git apply, patch and code review tools read — and Download .patch saves the same text as a file. The clipboard is the most compact way to paste a difference into a ticket or a chat; the file is what you attach or apply.

How large a text can it compare?

Thousands of lines a side compare in a few milliseconds. Matching lines at the start and end are settled first and the rest is split on lines that occur only once, so the work stays proportional to how much actually changed rather than to the size of the text.

Is my text uploaded anywhere?

No. The whole comparison runs in your browser, so contracts, logs, source code and anything else you paste here never leave your device. Nothing is uploaded, stored or logged.