DEVESSENTIALS

Diff Checker — Compare Code, Config Files & Text

Paste two versions of code, a config file or any text to compare them and highlight every difference. This code difference checker works at line, word and character level, so you can see a renamed variable or a changed port number without reading both files line by line.

Runs in your browser — nothing is uploaded.Both texts are compared on your device — safe for configs with secrets.

Original
Modified

Paste text in both panels to see the diff

How to compare two texts or code files

  1. Paste the original version on the left and the modified version on the right.
  2. Pick a mode: line for code and logs, word for prose and long config lines, character for tokens, hashes, URLs or a single changed digit.
  3. Scan the highlighted output: removed content is marked red, added content green. Unchanged lines stay neutral so the real changes stand out.

Worked example: comparing two config versions

Say production broke after a deploy and you want to know what changed in the config. Old version on the left, new on the right:

# before                         # after
server:                          server:
  port: 8080                       port: 8081
  timeout: 30s                     timeout: 30s
database:                        database:
  host: db.internal                host: db-replica.internal
  pool_size: 10                    pool_size: 10
                                   ssl: true

A line diff flags three lines: port, host and the new ssl key. Switch to character mode and it narrows port down to a single digit (0 → 1) and host to the inserted -replica — the kind of one-character change that is easy to miss in a code review and very hard to find by eye at 2 AM.

Tips for a clean config compare

  • Normalize formatting first. Run JSON through the JSON formatter with the same indent on both sides, or convert YAML with YAML to JSON, so only real changes remain.
  • Sort when order doesn't matter. For .env files and JSON objects, sort keys before comparing (sort, jq -S .).
  • Watch invisible characters. Windows line endings (\r\n), a UTF-8 BOM, tabs vs. spaces and trailing whitespace all produce differences that look like nothing. If two lines look identical, try character mode.
  • Compare rendered output, not just templates. For Helm or Terraform, diff the rendered manifests or plan output — that is what actually gets applied.

Why a diff checker should never upload your code

The files people diff are the ones that matter: production configs, .env files, Kubernetes manifests, database migrations. They are full of hostnames, passwords and API keys. When a tool processes or saves that text on its servers, it becomes part of someone else's data — and that data can leak. Researchers found that JSONFormatter and CodeBeautify had stored more than 80,000 user pastes (about 5 GB), including Active Directory credentials and cloud keys from banks and government agencies. Read how the JSONFormatter and CodeBeautify leak happened.

This diff tool computes the difference with the diff library running in your browser. There is no save or share button that would need a server, and no request is made with your text — you can confirm it in DevTools → Network.

Learn more

Browse all developer guides →

Related Tools

Frequently Asked Questions

How do I compare two config files?▾

Paste the old config on the left and the new one on the right, then use line mode to see which settings were added or removed and word or character mode to spot a changed value inside a line. For structured formats, normalize both sides first so formatting noise doesn't hide the real change: run JSON through a formatter with the same indentation, and for YAML convert both to JSON. For .env and INI files, sorting the lines (sort file.env) before comparing makes reordered keys disappear from the diff.

Can I compare two JSON files and ignore key order?▾

A text diff compares characters, so {"a":1,"b":2} and {"b":2,"a":1} show as different even though they are the same JSON object. Sort the keys on both sides first — jq -S . old.json > old.sorted.json does it on the command line — then paste the sorted versions here. Arrays are ordered in JSON, so a reordered array is a real difference.

Is it safe to compare code or configs that contain secrets?▾

With this diff checker, yes: both texts are compared by JavaScript in your browser and nothing is uploaded or saved on a server. That matters because configs are exactly where database passwords, API keys and connection strings live. Online tools that store pasted content have leaked exactly this kind of data — see the JSONFormatter and CodeBeautify leak. If you use any other diff tool, check DevTools → Network while you paste.

How do I compare two files from the command line?▾

Use diff -u old.txt new.txt for a unified diff, or git diff --no-index old.txt new.txt to get git's coloured output for any two files, even outside a repository. Add --word-diff to git diff for word-level changes, and -w to ignore whitespace. For directories, diff -ru dirA dirB compares recursively.

What algorithm does a diff tool use to find differences?▾

Most diff tools implement the Myers diff algorithm (1986), which finds the shortest edit script — the minimum set of insertions and deletions to transform one text into another. This is equivalent to finding the Longest Common Subsequence (LCS). It is the default algorithm used by GNU diff and git diff. The choice of algorithm matters because a poor implementation can produce technically correct but confusing results where logically related changes appear split across many unrelated hunks.

What is the difference between a line diff, a word diff, and a character diff?▾

A line diff compares documents line by line and marks entire lines as added or removed — the default mode and most useful for code. A word diff identifies which specific words within a changed line were altered (git diff --word-diff uses this). A character diff compares at the individual character level, most useful for catching typos, small config value changes, or comparing encoded strings. Many tools show a line diff with intra-line character highlighting as a hybrid approach.

What is unified diff format and how do I read it?▾

In unified diff format (produced by diff -u or git diff), lines prefixed with - are removed and lines prefixed with + are added. The @@ header shows the affected line ranges: @@ -10,7 +10,6 @@ means the original file at line 10 had 7 lines, the new file at line 10 has 6 lines. Unchanged context lines have no prefix. This format is standard for patch files and code review. Context diff (diff -c) is an older alternative that shows the two files in separate sections.

How are whitespace-only changes handled — can I ignore them?▾

By default, whitespace changes are treated as real differences. In git diff you can use --ignore-space-change (-b) to ignore changes in the amount of whitespace, or --ignore-all-space (-w) to ignore all whitespace entirely. This is essential when comparing code that was reformatted or had tabs converted to spaces. Note: ignoring whitespace can mask significant indentation changes in Python or YAML files where indentation is structurally meaningful.

Why do two files with identical visible content sometimes show differences?▾

Several invisible factors cause this: line endings (\r\n on Windows vs \n on Unix), a BOM (Byte Order Mark \xEF\xBB\xBF) at the start of a UTF-8 file, trailing spaces or tabs at the end of lines, and encoding differences (UTF-8 vs UTF-16 vs Latin-1). A diff showing differences between files that 'look the same' is almost always one of these. On macOS/Linux, cat -A reveals hidden characters; a hex viewer is the definitive diagnostic.