| 1 | function greet(name) { | 1 | function greet(name, greeting = "Hello") { |
| 2 | console.log("Hello, " + name); | 2 | console.log(`${greeting}, ${name}!`); |
| 3 | return true; | 3 | return true; |
| 4 | } | 4 | } |
About Diff Viewer
Diff Viewer compares two blocks of text and highlights what differs — line-by-line, with sub-line word-level highlighting so a single changed token in a long line is easy to spot. Pick the side-by-side layout for code-review-style reading, or the inline (unified) layout for the look of `git diff`. Whitespace and case sensitivity are configurable; line endings (CRLF vs LF) are normalised by default.
Reach for it whenever the question is what changed between two versions of any text: two SQL queries, two log files, two config snapshots, two paragraphs of prose, two stack traces, two outputs from the same command run on different machines. Diff Viewer is generic — it works on any text, parsing nothing. For semantic, key-aware diffs of JSON specifically (where key order is not significant), use JSON Diff. For applying or generating RFC 6902 patches programmatically, use JSON Patch.
Examples
left:
Hello, World!
This is line two.
right:
Hello, World!
This is line 2.(side-by-side: line 1 unchanged, line 2 highlighted with `two` → `2` at the word level)Word-level highlighting means a single token change is obvious without scanning the whole line.
Frequently asked questions
How is this different from JSON Diff?
Diff Viewer compares any text line-by-line — it does not parse the input. JSON Diff parses both sides as JSON and reports semantic differences by JSON path, ignoring key order. Use Diff Viewer when you want to see textual deltas; use JSON Diff when both sides are JSON and you want semantic equality.
Can I ignore whitespace differences?
Yes. Toggle the *ignore whitespace* option to collapse runs of whitespace before comparing — useful when the two inputs differ only in indentation (one tabs, one spaces) or trailing spaces.
Does it support more than two inputs?
No — Diff Viewer is a two-way diff. Three-way merging (left, base, right) is a separate operation and is not in scope here. For that, use a dedicated three-way merge tool or your editor's merge view.
Are line endings normalised?
Yes by default. CRLF and LF are treated as equivalent so a Windows-saved file diffs cleanly against a Unix-saved file. Toggle the option to keep them distinct when the line ending itself is what matters.
