Guide: Text Diff – Compare Two Texts
↑ Back to toolWhat is this tool?
This text diff tool compares two plain texts side by side or in a unified diff view. You paste or type content in Original (left) and Modified (right); the tool highlights line-by-line differences—additions in green, removals in red—so you can see exactly what changed. It works for logs, configs, code snippets, SQL, Markdown, or any two text blobs. You can swap sides, resize the panels, copy the diff, download it, or share a link that encodes both texts. All processing runs in your browser—your data is not sent to a server.
Why use a text diff tool?
Comparing two versions of a file, log, or snippet by eye is tedious and error-prone. A text comparison tool highlights added and removed lines at a glance, so you can review changes before committing, debug config differences between environments, or compare API responses and build outputs. Unlike a JSON diff (which compares by structure and keys), this tool treats input as plain text and diffs line by line, which is ideal for source code, log files, SQL scripts, Markdown, or any content where structure is not JSON.
For Developers
- • Compare two versions of a config or script
- • Review changes before committing to Git
- • Debug environment differences (dev vs prod)
For Everyone
- • Compare two drafts of an article or email
- • Spot differences in log files or command output
- • Share a comparison via link with a teammate
Key features
- Side-by-side view — Original (left) and Modified (right) with removed lines highlighted in red, added lines in green. Aligned rows make it easy to match up changes.
- Unified view — Single pane with
−for removals and+for additions, like classic unified diff format (diff -u). - Live diff — Diff updates as you type in either panel; no need to click a button.
- Resizable panels — Drag the divider to give more space to the left or right editor.
- Swap sides — One-click button to swap Original and Modified without copy-pasting.
- Change counts — Shows
+Nadded and−Nremoved in the diff header. - Copy diff — Copy the unified diff output to the clipboard for pasting in tickets or code reviews.
- Download — Download the diff as a
diff.txtfile. - Share — Generate a link that encodes both texts (base64 in the URL fragment). Opening the link restores left and right panels.
- Monaco Editor — Both input panels use Monaco (the VS Code engine) with syntax highlighting, line numbers, and word wrap.
- 100% client-side — Your text is not sent to any server. Processing runs entirely in the browser.
How this tool works (step-by-step)
- Paste Original text — Put the first (e.g. old) version in the left panel. Use "Load sample" to try it with example data.
- Paste Modified text — Put the second (e.g. new) version in the right panel.
- View the diff — The tool computes a line diff instantly and highlights additions (green) and removals (red). Switch between Side-by-side and Unified using the toggle above the result.
- Refine — Edit either panel and the diff updates live. Use Swap to flip sides. Drag the divider to resize panels.
- Copy, download, or share — Use "Copy diff" to copy the unified diff to clipboard, "Download" to save as
diff.txt, or "Share" to get a link.
Real-world examples with code snippets
Comparing two config files
Paste the old config in the left panel and the new config in the right. The diff highlights which lines were added, removed, or changed—useful for environment or feature-flag changes:
// Original (left) // Modified (right)
DATABASE_HOST=localhost DATABASE_HOST=db.prod.internal
DATABASE_PORT=5432 DATABASE_PORT=5432
DEBUG=true DEBUG=false
LOG_LEVEL=warn
// Diff result:
- DATABASE_HOST=localhost → removed
+ DATABASE_HOST=db.prod.internal → added
- DEBUG=true → removed
+ DEBUG=false → added
+ LOG_LEVEL=warn → addedComparing log outputs
Paste two log excerpts (e.g. before and after a deploy) to see which lines appeared or disappeared. This is faster than scanning hundreds of lines manually:
// Before deploy (left) // After deploy (right) [INFO] Starting app v2.1.0 [INFO] Starting app v2.2.0 [INFO] Connected to DB [INFO] Connected to DB [WARN] Cache miss rate high [INFO] Cache warmed in 120ms [INFO] Ready on :3000 [INFO] Ready on :3000 // Diff shows: - [INFO] Starting app v2.1.0 + [INFO] Starting app v2.2.0 - [WARN] Cache miss rate high + [INFO] Cache warmed in 120ms
Comparing SQL queries
Paste two versions of a SQL query to see which clauses changed—useful when debugging slow queries or reviewing migrations.
Use cases
| Scenario | How this tool helps |
|---|---|
| Config or env files | Compare dev vs prod or before/after a change to see exact line differences instantly. |
| Code or scripts | Compare two versions of a snippet, function, or SQL query when you don't need a full structural diff. |
| Logs or build output | See which lines appeared or disappeared between two runs, deploys, or environments. |
| Writing or documentation | Compare two drafts of an article, README, or email to catch wording changes. |
| Share a comparison | Share a link so a teammate can open the same two texts and view the diff—no file attachments needed. |
Best practices
- Normalize line endings — If one text uses
CRLF(Windows) and the otherLF(Unix), every line may appear changed. Normalize before comparing for a cleaner diff. - Trim trailing whitespace — Extra spaces at the end of lines can cause false positives. Trim both texts if whitespace isn't significant.
- Use side-by-side for context — Side-by-side view is best when you need to see old and new simultaneously. Use unified view for a compact patch-style output.
- Share instead of screenshot — The Share link encodes both texts, so the recipient gets an interactive diff—not a static image.
- For structured data, use the right tool — JSON payloads are better compared with the JSON Diff tool (structure-aware). This text diff is line-based and best for plain text, code, and logs.
Common mistakes & how to avoid them
- Pasting in the wrong order — Original should go on the left and Modified on the right. If you get it backwards, click the ⇄ Swap button instead of re-pasting.
- Comparing JSON by text — Text diff shows line-level changes, so reordering keys will show as many removed/added lines even if nothing meaningful changed. Use the JSON Diff tool for JSON.
- Huge inputs slowing the browser — The diff runs client-side; very large texts (100k+ lines) may cause the tab to lag. For enormous files, use a local diff tool or split the input.
- Expecting word-level highlighting — This tool diffs at the line level. If a single character changed on a line, the entire line is marked. For character-level diffs within a line, pair with manual inspection.
FAQ
What is the difference between text diff and JSON diff?
Text diff compares two plain texts line by line and shows added/removed lines. JSON diff compares two JSON objects by structure and keys, ignoring key order, and can export a structural diff report. Use text diff for logs, configs, code, or any non-JSON text; use JSON diff for JSON payloads or configs.
Is my text sent to a server?
No. The diff is computed entirely in your browser using the 'diff' library. Your content is not uploaded. Share links encode the text in the URL fragment (hash), which is never sent to the server.
Can I compare more than two texts?
This tool compares two texts at a time (Original vs Modified). For three-way or multi-file comparisons, run separate diff sessions or use a local merge tool.
How does Share work?
Share encodes both the left and right text into the URL fragment as base64. Anyone with the link can open it and see the same two texts and diff. The data lives in the URL—not stored on a server—so very large texts may exceed URL length limits.
Does it support character-level diff?
Currently the tool diffs at the line level. A changed line is highlighted as removed + added. Character-level inline highlighting is not yet available.
What diff algorithm is used?
The tool uses the 'diff' npm package (diffLines function), which implements the Myers diff algorithm—the same algorithm used by Git.
Can I use keyboard shortcuts?
The Monaco editors support standard shortcuts (Ctrl/Cmd+A to select all, Ctrl/Cmd+Z to undo, etc.). The Swap, Copy, and Download buttons are in the toolbar.
Is it free?
Yes. The text diff tool is completely free with no sign-up required. All processing runs in your browser.
Related terms
This tool is commonly searched as text diff, compare text online, text comparison tool, side by side diff, unified diff, string diff, online diff checker, compare two files online, diff two strings, and line-by-line comparison. It helps you spot changes between any two text blobs without installing software or leaving the browser.
Similar tools
You might also find these developer tools useful:
Conclusion
A text diff tool makes it easy to compare two texts side by side or in unified view, with line-level add/remove highlighting, swap, resize, copy, download, and share—all in the browser with no sign-up. Use it for configs, logs, code snippets, SQL, Markdown, or any two text blobs when you need a quick, private comparison without installing software or sending data to a server.