Diff Checker — Compare Code and Config Files, Get a Unified Diff

Paste two versions of a file, such as code, JSON, YAML or a config, to see the changed lines highlighted and get a unified diff you can save as a patch.

Live demo · real result from this tool
Compare
Added3 lines
Removed
2 lines
Unchanged
5 lines

Differences

Unified diff

--- original+++ changed@@ -1,7 +1,8 @@ server:-  port: 8080+  port: 9090   host: 0.0.0.0-logging: info+logging: debug features:   - auth   - billing+  - search 

Processed on your device — nothing is uploaded.

How to use the diff checker

  1. Paste the earlier version into Original.
  2. Paste the newer version into Changed.
  3. Choose Compare: Lines for code and config, Words or Characters for small edits inside a line.
  4. Tick Ignore whitespace to skip indentation changes, or Ignore case to treat capitals and lower case as equal.
  5. Review the highlighted Differences. In Lines mode, copy or download the Unified diff.

What it does and when to use it

This tool is built for developers’ everyday comparisons, where the answer you need is a precise list of changed lines:

  • Config drift. Compare the YAML or .env layout from staging with production to find the setting that differs.
  • Reviewing a snippet. See what a colleague changed in a function they pasted into chat.
  • Before and after a formatter. Check that running a formatter changed only spacing.
  • Making a patch. Produce a unified diff to attach to an issue or apply with git apply or patch.
  • Checking generated output. Compare an API response or a build artefact against a known good copy.

For comparing prose, such as edits to an article or a contract, the Text Comparison tool in the Writing Studio is a better fit. To test a pattern before a find-and-replace across files, use the Regex Tester. To check that two downloads are byte-for-byte the same, compare their hashes with the Hash Generator.

How it works

The tool uses the open-source diff library, which runs in your browser. In Lines mode it finds the longest sequence of lines the two versions share and marks the rest as added or removed, so a moved block or an inserted line does not make the whole file look different. The unified diff includes three lines of context around each change, the same default git uses.

Words and Characters modes compare smaller pieces and show changes inline, with removed text struck through and added text highlighted. The counts at the top show how many lines, words or characters were added, removed or left unchanged.

Worked examples

A YAML config. The original sets port: 8080 and logging: info. The changed file sets port: 9090, logging: debug and adds - search to the features list. The result is Added: 3 lines, Removed: 2 lines and Unchanged: 5 lines. The unified diff starts with the header @@ -1,7 +1,8 @@, meaning 7 lines from line 1 became 8 lines from line 1.

Re-indented code with Ignore whitespace. The function body moved from two spaces to four, and the first line changed from function add(a, b) { to function add(a,b){. With Ignore whitespace on, the re-indented return line counts as the same, giving Unchanged: 2 lines. The first line is still reported, because spaces inside a line are not ignored.

Two identical inputs. The tool shows The two texts are identical instead of an empty diff.

Limits and tips

  • Very large files can take a moment to compare, because the work happens on your device.
  • Ignore whitespace does not apply in Words or Characters mode.
  • For the clearest results with JSON, format both sides the same way first, with consistent indentation and key order.

Frequently asked questions

Why does every line show as changed?
Usually because of line endings. A file saved on Windows uses CRLF line endings and one saved on macOS or Linux uses LF, so every line looks different even though the text is the same. The tool warns you when the two sides use different line endings.
What does Ignore whitespace do?
In Lines mode it ignores spaces and tabs at the start and end of each line, so re-indented code is not reported as changed. Spaces in the middle of a line still count, so "a, b" and "a,b" are different.
What is a unified diff?
It is the standard text format for changes, used by git, patch and most code review tools. Lines starting with a minus were removed, lines with a plus were added, and the @@ header shows which line numbers each change covers. You can download it as changes.diff.
Can I compare JSON objects regardless of key order?
Not with this tool, which compares text. Two JSON files with the same data in a different key order will show differences. Format both with the same tool first, or use a JSON-specific comparison.
Is my code uploaded?
No. The comparison runs in your browser, so source code, configs and secrets in them never leave your device.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close