Diff Checker
Compare two blocks of text and highlight differences
What is Diff?
A diff (short for "difference") is a comparison between two pieces of text that identifies exactly what was added, removed, or changed. The concept originates from the Unix diff utility created in the early 1970s, which became foundational to version control systems, code review workflows, and collaborative editing. Today, diffs are everywhere developers work — in git commits, pull request reviews, deployment pipelines, and configuration management.
The core challenge of diffing is producing a minimal, meaningful set of changes. Given two versions of a document, there are many possible ways to describe the transformation from one to the other — but the most useful diff is the one that matches human intuition about what "actually changed." A good diff algorithm finds the longest common subsequence between the two texts and reports everything else as additions or deletions, minimizing noise.
Diff tools become essential whenever you need to answer the question "what changed?" — whether comparing two configuration files, verifying that a code refactor did not alter behavior, reviewing edits from a colleague, or investigating why a deployment broke something that worked yesterday. A browser-based diff checker provides this capability without installing software or configuring a repository.
How it works
The diff algorithm at the core of this tool computes the longest common subsequence (LCS) between the two input texts, split by lines. Lines present in both texts in the same order are considered unchanged; lines present only in the first text are deletions; lines present only in the second are additions. Lines that exist at the same position but differ in content are marked as modifications. This is the same fundamental approach used by git diff and the classic Unix diff command.
For word-level highlighting within modified lines, the tool performs a second pass. Once two corresponding lines are identified as "changed," it tokenizes both into words and runs the same LCS algorithm on the word sequences. Words unique to the first version are highlighted as removed, words unique to the second as added, and shared words are left unmarked. This two-level approach provides both the structural overview (which lines changed) and the precise detail (which words within those lines changed).
The results are displayed in a side-by-side or unified format, with color coding — green for additions, red for deletions, and yellow or blue for modifications. Line numbers from both inputs are shown so you can correlate the diff output with the original files. The rendering preserves whitespace and indentation so that changes in formatting are visible alongside changes in content.
How to use this tool
- Paste the original text (the "before" version) into the left input panel, and the modified text (the "after" version) into the right panel.
- The diff results appear automatically, with additions highlighted in green, deletions in red, and modifications shown with word-level highlighting so you can see exactly what changed within each line.
- Use the line numbers on each side to correlate changes with the original files. Unchanged lines provide context around the modifications.
- Toggle between side-by-side and unified diff views depending on your preference. Side-by-side is better for comparing long lines; unified is more compact for quick scanning.
- For structured data like JSON or XML, consider formatting both inputs with consistent indentation before diffing to ensure the comparison reflects actual data changes rather than whitespace differences.
Examples
Comparing two versions of a configuration file
Paste the old and new nginx.conf (or any config file) into the two panels to see exactly which directives were added, removed, or modified. This is faster than scanning the file manually and catches changes you might overlook, like a subtle port number change or an added header.
Verifying that a refactor did not change output
Run your application with the old code and capture the output, then run it with the refactored code and capture that output. Paste both into the diff checker to confirm they are identical. Any differences indicate a behavioral change introduced by the refactor.
Reviewing API response differences between environments
Capture an API response from staging and the same endpoint from production, then diff them. This quickly reveals field-level differences — missing keys, different values, additional data — that might explain environment-specific bugs.
Tracking changes in database schema SQL
Compare the CREATE TABLE statements from two database versions to see which columns were added, which constraints changed, and which indexes were modified. This is useful when reviewing migration scripts or diagnosing schema drift between environments.
About this tool
Paste two snippets of text, code, or JSON to see line-by-line differences highlighted in a familiar diff format. Supports word-level diffing for precise change detection.
Common use cases
- • Comparing two versions of a configuration file to find what changed
- • Reviewing code changes before committing when you don't have a git diff handy
- • Checking API response differences between staging and production environments
- • Verifying that a minified or formatted file matches the original content
Frequently asked questions
- What diff algorithm does this tool use?
- The tool uses a line-by-line diff algorithm that identifies additions, deletions, and modifications. It also supports word-level highlighting within changed lines to pinpoint exactly what was modified.
- Can I compare code in different languages?
- Yes. The diff checker works with any text content regardless of language or format — code, JSON, YAML, plain text, CSV, or any other text-based format.
- Is there a size limit for the text I can compare?
- The tool handles reasonably large text inputs (tens of thousands of lines) efficiently in your browser. For very large files, performance depends on your device.
- What is the difference between line-level and word-level diffing?
- Line-level diffing marks entire lines as added, removed, or changed. Word-level diffing goes further by highlighting the specific words within a changed line that actually differ. For example, if you change "color: red" to "color: blue", line-level diff marks the whole line as modified, while word-level diff highlights only "red" vs "blue". This makes it much easier to spot small changes in long lines.
- Can I use this tool to compare JSON or YAML files?
- Yes, but for the best results with structured data, first format both inputs with consistent indentation using the JSON Formatter or YAML converter. Diffing unformatted vs. formatted JSON will show every line as changed even if the data is identical. Normalizing the formatting first ensures the diff reflects actual data differences.
- How do I compare files from my local machine?
- Copy and paste the contents of each file into the two input panels. The tool does not access your file system directly — all processing happens in the browser with text you provide. For frequent file comparisons, your IDE or git diff may be more convenient, but this tool is ideal for quick one-off comparisons without any setup.