Online Text Diff Tool: Compare Two Texts Side by Side
What Is Text Diff
Text Diff means comparing two strings and marking what changed. git diff is the familiar form: an edit script of insertions and deletions, not a replay of the author's keystrokes.
The Text Diff tool is for snapshots you already have—configs, API bodies, log slices, code excerpts—compared in the browser with side-by-side or unified layout. Processing stays local. For commit history, keep using git log -p.
Why You Need Text Diff Comparison
- Code-snippet review: See what changed in a function or draft patch
- Configuration management: Diff Nginx,
.env, or Compose fragments across environments - Docs and translation: Catch missing or extra paragraphs
- Log analysis: Find the lines that actually drifted
- Pre-pass before structural diff: Spot serialization noise before JSON/YAML semantic compare
How to Use ToolVault Text Diff
Open the Text Diff tool:
- Paste Original on the left and Modified on the right
- There is no Compare button — the diff view appears as soon as either side has content
- Optionally enable Ignore whitespace (per-line
trim) and Ignore case (lower-case both sides) - Toggle side-by-side vs unified layout
- Read the stats bar:
+added / -removed / ~modified / =unchangedplus line counts
Monaco colors additions green-ish and deletions red-ish. A “modification” usually appears as delete-old + add-new. The ~modified counter comes from a separate index-aligned tally (see Implementation notes)—not a distinct yellow highlight mode.
Example / Swap / Clear load a sample, swap panes, or wipe both. Inputs persist in local storage for the browser profile—Clear after pasting secrets.
Algorithms: LCS, Myers, Patience, Histogram
Line diffs aim for a short edit script, not your mental model of the edit.
| Name | Intuition | Where you meet it |
|---|---|---|
| LCS DP | Longest common subsequence; non-LCS lines are changes | Textbooks, simple ports |
| Myers | Shortest path on an edit graph; memory-friendly | Classic git diff |
| Patience | Anchor on unique common lines, recurse | git diff --patience; often clearer on moves |
| Histogram | Frequency buckets; improves Patience on repeats | Newer Git defaults |
Diff output is not unique. Several minimal paths can all be correct—two tools disagreeing on hunk shape does not mean either is wrong.
Before: After:
apple apple
banana cherry
cherry date
date
An LCS of apple → cherry → date reads as “delete banana, insert cherry somewhere”—not “rename banana to cherry.” When a moved block looks shredded, try Patience/Histogram in Git, or normalize ordering before diffing.
Complexity
Naive LCS is about O(m×n). A few thousand lines stay interactive in the browser; six-figure line counts should move to local git diff / diff -u or be sliced.
Side-by-Side vs Unified; Line vs Character
This tool switches layout (side-by-side vs unified), not a “line mode / character mode” algorithm pair.
| Granularity | Good for | Notes |
|---|---|---|
| Line | Code, configs | Primary alignment unit in Monaco Diff |
| Inline character highlights | Changed lines | Monaco marks in-line edits (extra space, quote drift) |
| Word-level | Prose reflow | Not a separate mode here; use git diff --word-diff locally |
If Monaco fails to load, the fallback compares line i to line i. An insertion in the middle marks every following line as changed—weaker than Monaco’s Myers-style alignment.
Whitespace, Case, CRLF
Ignore whitespace (actual behavior)
Ignore whitespace runs trim() on each line before diffing. It does not:
- Collapse internal spaces (
a bvsa bstill differs) - Match
git diff -w/diff -w - Drop blank lines or normalize indentation style
Keep it off for YAML, Python, Makefiles. Turn it on for prose or noisy logs. For stronger cleanup, use the whitespace remover first.
Ignore case
Lower-cases both sides. Handy for mixed log levels; wrong when case is semantic.
CRLF vs LF
\r\n vs \n makes identical-looking lines differ. Normalize line endings first. Trailing blank lines, BOM, and zero-width characters show up under inline highlights.
Reading a Unified Diff / Patch
diff --git a/app.conf b/app.conf
--- a/app.conf
+++ b/app.conf
@@ -1,4 +1,5 @@
listen 80;
-server_name example.com;
+server_name www.example.com;
+access_log /var/log/nginx/access.log;
---/+++: file paths (not content)@@ ... @@: hunk header (old/new ranges)- Leading space: context
-/+: removed / added- Adjacent delete+add blocks: often one logical edit
Already have a unified patch and want +N -M, file count, and a rough feature/docs/style guess? Use Diff Summary—it parses patch text, it does not compare two free-form panes. Pane compare stays on Text Diff.
Practical Use Cases
Configuration troubleshooting
Diff last-known-good vs current. Align line endings, then experiment with ignore-whitespace. For YAML/Compose, YAML ↔ JSON and the YAML JSON guide explain serialization traps that look like huge diffs.
API responses and JSON
Reorder and indent noise dominate raw bodies. Format with the JSON formatter, use JSON Diff for semantic trees (JSON Diff guide), and keep text diff for already-normalized dumps or semi-structured logs.
Translation and copy
Check omissions; normalize case with the case converter when needed. To extract lines before comparing, see the regex guide and regex tester.
Environment and list-like text
Reordered identical lines become mass delete+add. Sort or dedupe first.
Implementation notes
Behavior of DiffTool + DiffViewer (DiffEditor from @monaco-editor/react, assets under /monaco-editor/vs):
- Engine: Monaco DiffEditor (line alignment + inline character highlights on changed lines). Fallback after load timeout: index-aligned line compare—weaker when lines are inserted mid-file.
- No separate character-mode toggle: character detail is Monaco’s inline highlight, not a full-text character LCS mode.
- Ignore whitespace: per-line
trimonly—notdiff -w. - Ignore case: full-string lower-casing.
- Stats bar:
computeDiffStatscounts by matching indices; it can disagree with Monaco’s minimal edit script. Trust the diff view for review; treat stats as volume hints. - No ignore-pattern regex: only whitespace and case toggles exist in the UI.
- Local-only compute; inputs persist via
usePersistentState—Clear on shared machines.
FAQ
What formats are supported?
Any plain text—code, JSON, XML, CSV, logs. The tool does not parse structure.
Will large files be slow?
Thousands of lines are usually fine. Hundreds of thousands should be sliced or handled with local diff.
Does the tool upload my data?
Diffing runs in the browser. Persistence keys stay in that browser profile; Clear after sensitive pastes.
Texts look identical but still differ?
CRLF/LF, trailing blank line, trailing spaces, tab vs spaces, BOM, zero-width characters. Diff with ignore-whitespace off first, or normalize with the whitespace tool.
Text Diff vs JSON Diff vs Diff Summary?
| Need | Tool |
|---|---|
| Two plain-text / config snapshots | Text Diff |
| Semantic JSON tree diff | JSON Diff |
| Summarize an existing unified patch | Diff Summary |
Further reading
- JSON Diff guide — key order, arrays, integer precision, semantic compare
- JSON formatting guide — normalize before text diff
- YAML ↔ JSON guide — why configs look fully rewritten
- Regex guide — extract or filter noisy lines first
From the ToolVault developer notebook. Browse more online tools on the homepage.
Related Tools
Related Articles
Markdown to Word: Native Style Mapping and the Inline-Format Downgrade List
Turning a Markdown draft into a deliverable .docx: pandoc CLI vs in-browser local conversion, how headings/tables/code blocks map to native Word styles, which inline formats degrade to plain text, and why 'editable' beats 'looks right'.
Word to Markdown: Two Clean Paths and What Survives the Conversion
How to convert .docx to Markdown cleanly: pandoc CLI vs in-browser local conversion, a format fidelity table for headings/tables/images/auto-numbering, and fixes for the .doc legacy format, image bloat, and merged-cell tables.
China License Plate Rules and Validation: Standard, New Energy, and Special Formats Explained
Mainland China plate encoding rules in full: the standard blue plate, the GA36D-2018 new-energy format, armed police and embassy plates, province abbreviations and issuing-authority letters — with an online validator.