Skip to content
cosmodev ~/tools/text-diff

Trình so sánh văn bản

Text & String

So sánh hai đoạn văn bản và thấy chính xác điều gì đã thay đổi. Đánh dấu dòng, từ hoặc ký tự được thêm và bớt, hiện tóm tắt từng phía, và xuất unified diff để dán vào PR hoặc commit. Chạy 100% trong trình duyệt.

+0 đã thêm−0 đã xóa0 không đổisố đếm tính theo ký tự

Nhập văn bản vào cả hai ô để xem khác biệt.

Unified diff
--- original
+++ changed

(Tài liệu bằng tiếng Anh)

What it does

The Text Diff Viewer compares two pieces of text - an original and a changed version - and shows exactly what was added, removed, and left untouched. It uses a classic LCS (longest-common-subsequence) algorithm with no dependencies, so the diff is deterministic and runs entirely in your browser. Switch the granularity between Line, Word, and Char to zoom in on the change that matters. Every view comes with a summary of characters added/removed/unchanged and a copy-ready unified diff for patches, PRs, or commit messages.

How to use it

  1. Paste the original text into Original and the new version into Changed (or hit Sample for a worked example).
  2. Pick a granularity with Line / Word / Char - line is best for code, word/char for prose or short strings.
  3. Read the colored result: green is added, red is removed, muted text is unchanged. The badges show character counts.
  4. Use Copy unified diff to grab a standard +/-/@@ patch, or Copy share link to reproduce the exact comparison.

Examples

Function rewrite (line granularity)

Original:

function greet(name) {
  return "Hello, " + name;
}

Changed:

function greet(name) {
  return `Hello, ${name}!`;
}

Diff output:

 function greet(name) {
-  return "Hello, " + name;
+  return `Hello, ${name}!`;
 }

Word-level edit

"The quick brown fox"  →  "The slow brown dog"

Output highlights quick→slow (removed/added) and fox→dog, leaving The and brown unchanged.

Good to know

  • Shareable: both texts and the granularity are encoded in the URL, so a link reproduces the exact comparison.
  • Private: all comparison happens locally - your text never leaves your machine.
  • Related tools: JSON Formatter, JSON → TypeScript, Base64Base64An encoding representing binary data as 64 safe ASCII characters, so it survives transport through text-only channels. It encodes — it does not encrypt..
Mã nguồn14 ngôn ngữ

100% phía client · dữ liệu của bạn không bao giờ rời khỏi trình duyệt. Thấy hữu ích? Chia sẻ với đồng nghiệp của bạn.