How to use the code diff checker
Put the earlier code in Original and the later code in Modified. The viewer marks added, removed, and unchanged lines, while the controls let you choose a view, set whitespace rules, and copy a unified-style patch.
- Paste code into Original and Modified, or select Upload below the panel that should receive a file.
- Leave Language on Auto-detect, or select JavaScript, Python, JSON, Plain text, or another listed language.
- Choose Side-by-side or Unified. Check the line numbers, highlighted changes, and Similarity, Added, Removed, and Unchanged values.
- Select Copy patch in Unified patch after the patch output appears.
Compare code with whitespace controls
- Ignore leading/trailing whitespace removes spaces and tabs from both edges of each line before the tool checks for a match.
- Ignore whitespace differences changes each run of spaces or tabs to one space, then trims the line used for comparison. The source in the viewer stays unchanged.
- Show whitespace as visible spaces changes how spacing is displayed in the viewer. It does not change which lines the diff compares.
Read side-by-side or unified code differences
The comparison uses a line-based Myers diff. Side-by-side keeps Original and Modified in separate columns. Unified puts additions, removals, and nearby unchanged lines in one stream. Long unchanged runs can be collapsed into clickable summaries with three lines of context. The statistics count line operations.
Original: const total = 1;
Modified: line 1 changed
Output: -const total = 1;
+line 1 changed
Auto-detect checks Modified first and uses Original when Modified is empty. It looks for code patterns, then falls back to Plain text when no supported pattern wins. A manual language choice changes syntax highlighting without changing the line comparison.
Copy a unified code patch
Unified patch appears after either input contains text. The output starts with a/original and b/modified, then lists hunks with up to three nearby unchanged lines. Identical inputs produce an empty patch, so Copy patch stays disabled. The page does not run git apply to validate the result.
Use the code diff checker with common source files
- Compare a revised JavaScript function with its earlier version, then copy the patch into a review note.
- Compare JSON or YAML files after a configuration edit, and use Ignore whitespace differences when spacing changes should not split matching lines.
- Check Markdown or HTML source in Unified when additions and removals are easier to follow in one stream.
Choose the right comparison tool
Compare Tools groups this code comparison with tools for other inputs. Choose Compare Text for word-, line-, or character-level changes in plain text. Choose Compare Lists for items found only in one list, shared items, or duplicates. Choose HTML Diff Checker for a source diff plus sanitized before-and-after HTML previews.
Frequently asked questions
How does the code diff checker detect the language?
Auto-detect checks Modified first and uses Original when Modified is empty. It checks code patterns for syntax highlighting and falls back to Plain text when no supported pattern wins.
What does a code difference checker compare?
It compares lines with a Myers diff and reports Similarity, Added, Removed, and Unchanged. The view can show Original and Modified side by side or as one Unified stream.
Can I compare code while ignoring whitespace?
Yes. Ignore leading/trailing whitespace removes edge spacing from comparison keys. Ignore whitespace differences changes each run of spaces or tabs to one space and trims the key before comparing lines. The displayed source remains unchanged.
How do I copy a code diff patch?
Enter code in either panel, then select Copy patch in Unified patch. Identical inputs leave the patch output empty and the button disabled.
Does the code diff checker send my code anywhere?
The page's comparison, highlighting, and patch generation run in client-side JavaScript. This tool script does not send entered code to a server. The page does not state broader storage or security guarantees.