Side by Side and Unified
Compare versions in two aligned columns, or switch to a unified diff with plus and minus lines like git diff.
Compare two versions of code or text and see exactly what changed. Side-by-side and unified views, word-level highlighting, ignore whitespace and a downloadable diff.
Add the original on the left and the changed code on the right.
Ignore whitespace or case, and choose side-by-side or unified view.
Jump between changes, then copy or download the diff.
Sooner or later, every developer has to answer the same question: what exactly changed between these two versions? It might be a function that worked yesterday and fails today, a config file that was edited on the server, a pull request that touches too many files, or a block of code pasted from a colleague that looks almost the same as yours. Reading two files line by line is slow and easy to get wrong. Our free code diff checker does it for you in a second. Paste the original and the changed code, and the tool aligns them, highlights every added, removed and modified line, and even marks the individual words that changed inside a line. You can view the result side by side or as a unified diff like the output of git diff, ignore whitespace and letter case so that reformatting does not drown out the real changes, collapse long unchanged sections, jump from change to change, and copy or download the result as a diff file. It works with any programming language or plain text, runs completely in your browser and needs no signup.
Think of it as an online diff tool, a text compare tool and a git diff viewer in one page. Use it to compare two files online, find the difference between two pieces of code, check a config before you deploy it or review a patch before you commit it. The Compare button runs the comparison, and you can move between changes with Previous change and Next change. It works on Windows, Mac, Linux, Android and iPhone, with JavaScript, PHP, Python, Java, C#, SQL, HTML, CSS, JSON, YAML and any other plain text, and your code never leaves your browser.
Compare versions in two aligned columns, or switch to a unified diff with plus and minus lines like git diff.
See exactly which words changed inside a modified line, instead of comparing long lines by eye.
Ignore whitespace and case, collapse unchanged lines, then copy or download a unified diff.
You can compare two versions in a few seconds, and the result updates as you edit.
A diff, short for difference, is a description of the changes between two versions of a file. It is one of the oldest and most useful ideas in software development, and it is the foundation of version control systems such as Git, code review tools and patch files. A diff tells you which lines were removed from the old version, which lines were added in the new version and which lines stayed the same. Instead of looking at two complete files, you only have to look at the changes, which makes it much easier to review, understand and discuss them. Our diff checker uses the Myers algorithm, the same approach that is used by default in Git, to find the smallest set of line changes between your two texts.
The unified diff format is the standard way to show changes in text form. It starts with two header lines that name the old and new file, followed by one or more hunks. Each hunk begins with a line like @@ -3,5 +3,6 @@, which says that it covers five lines starting at line 3 in the old file and six lines starting at line 3 in the new file. Below it, lines that start with a space are unchanged context, lines that start with a minus sign were removed, and lines that start with a plus sign were added. This is the format that git diff prints and that patch tools can apply, so a diff that you download here can be used in code reviews, bug reports and tickets.
--- a/original
+++ b/modified
@@ -1,4 +1,4 @@
function total(items) {
- return items.reduce((a, b) => a + b, 0);
+ return items.reduce((sum, n) => sum + n, 0);
}
Many changes in a codebase are not real changes at all. A formatter may have re-indented a whole file, a Windows editor may have changed the line endings, or somebody may have added trailing spaces. If you compare the files exactly, every one of those lines is shown as a difference, and the real change is hidden in the noise. The whitespace options solve this. Ignore trailing spaces skips spaces at the end of lines, the second option also ignores leading spaces and collapses repeated spaces, and ignore all whitespace removes every space and tab before comparing. Line endings are always normalized, so Windows and Unix files can be compared without any difference. There is also an option to ignore letter case, which is useful for case-insensitive languages and for SQL keywords or HTML tags.
The tool splits both texts into lines, normalizes them according to your whitespace and case options, and then looks for the longest sequence of lines that appear in both versions in the same order. Everything outside that sequence is a change: lines that are only in the original are shown as removed, and lines that are only in the new version are shown as added. When a block of removed lines is followed by a block of added lines, the tool pairs them as modified lines and runs a second comparison on the words inside each pair, which is how it highlights the exact words that changed. Long unchanged stretches are collapsed to keep the focus on the differences, and you can expand any of them with one click. The comparison is language-independent, so it does not need to understand your code.
This is a line-based comparison tool for two files or two pieces of text. It does not understand the syntax of a language, so a block of code that was moved to a different place is shown as removed in one place and added in the other. It does not do three-way merges, folder comparison or version history. Each side can be up to 2 MB, and when two very large texts are almost completely different, the tool shows a simplified result to stay fast. Binary files are not supported.
The result uses the same conventions as most code review tools, so it feels familiar if you have used Git. This table explains every marker you will see.
| Marker | Meaning | Where you see it |
|---|---|---|
Red line, - | The line exists only in the original version, so it was removed or changed | Left side and unified view |
Green line, + | The line exists only in the changed version, so it was added or changed | Right side and unified view |
| Stronger highlight | The exact words that changed inside a modified line | Both sides, when Highlight changed words is on |
| Plain line, space prefix | Unchanged context that helps you find your place | Around every change |
@@ -3,5 +3,6 @@ | A hunk header with the line numbers and sizes of the changed block | Copied and downloaded unified diff |
Both views show exactly the same changes. Pick the one that fits what you are doing, and switch at any time without comparing again.
| Side by side | Unified | |
|---|---|---|
| Layout | Original on the left, changed version on the right | One column with minus and plus lines |
| Best for | Reading and understanding changes | Sharing, patches and pull request comments |
| Screen space | Needs a wider screen | Works well on narrow phone screens |
| Matches | Visual editors and merge tools | The output of git diff |
These settings decide which differences count. Choosing the right one is the quickest way to remove noise from a diff.
| Option | What it ignores | Use it when |
|---|---|---|
| Compare exactly | Nothing, apart from line endings, which are always normalized | Every space matters, for example in Python, Makefiles or YAML |
| Ignore trailing spaces | Spaces and tabs at the end of lines | An editor added or removed invisible spaces |
| Ignore leading, trailing and repeated spaces | Indentation changes and repeated spaces inside a line | A file was re-indented or reformatted |
| Ignore all whitespace | Every space and tab | You only care about the words and symbols |
| Ignore letter case | Differences between upper and lower case | Comparing SQL keywords, HTML tags or case-insensitive text |
A diff works on plain text, so it can compare almost any file you can open in a text editor. These tips make the result easier to read for common formats.
| File type | What to compare | Tip |
|---|---|---|
| JSON | API responses, package.json, settings files | Format both sides with the same indent and sorted keys first |
| SQL | Queries, migrations and stored procedures | Turn on Ignore letter case |
| HTML and CSS | Templates, page source and stylesheets | Use Ignore leading, trailing and repeated spaces |
| Config files | .env, YAML, INI and server configs | Compare exactly, and hide secrets before you paste |
| Logs and text | Two log files, translations or contracts | Show everything to see the full context |
| Source code | Two versions of a function or a whole file | Compare small pieces to keep the diff readable |
If the result is not what you expected, one of these causes is usually behind it.
| Problem | Likely cause | How to fix it |
|---|---|---|
| Every line is marked as changed | The file was re-indented or the spaces differ | Choose an ignore whitespace option |
| Additions and removals look reversed | Original and changed code are on the wrong sides | Click Swap sides and compare again |
| No differences found | The texts are identical, or an ignore option hides the change | Set Whitespace to Compare exactly and turn off Ignore letter case |
| Moved code appears twice | The tool compares lines in order and does not detect moves | Read it as removed in one place and added in the other |
| The result looks simplified | The two texts are very large and almost completely different | Compare smaller sections of the file |
| A file will not open | It is a binary file, or it is larger than 2 MB | Open a text file, or paste the part you need |
Developers have several ways to compare text. An online diff checker is the fastest when you only have two snippets or files and no repository.
| Method | Setup needed | Best for |
|---|---|---|
| Online diff checker | None. Open the page and paste | Quick checks, snippets, server files and sharing a result |
| git diff | A Git repository and the command line | Tracked changes between commits and branches |
| Editor or IDE compare | An installed editor with a compare feature | Everyday work on local projects |
The diff checker runs in your web browser, so you can compare code on Android, iPhone, Windows, Mac and Linux without installing anything. On a phone, switch to the Unified view, which needs less width. On a desktop, use the Side by side view to see both versions at once. The steps are the same in Chrome, Edge, Firefox and Safari.
Our code diff checker runs completely in your browser. The text you paste or open is not uploaded or stored on a server. As a general habit with any online tool, remove real passwords, API keys and private tokens before you paste a config file, and replace them with dummy values.
Comparing code is often combined with other small jobs. These free tools make the rest easier:
Our free code diff checker helps you to find, review and share the differences between two versions of code in seconds. Paste both versions, choose your options and read the changes line by line and word by word, with no signup and without your code leaving your browser.
Quick answers about comparing code and text with the diff checker.
A code diff checker compares two versions of code or text and highlights what was added, removed or changed. It is useful for reviewing edits, finding what broke between two versions, comparing a config file before and after a change, and checking pasted code against the original.
Paste the original code on the left and the changed code on the right, or open files from your computer. The differences appear right away, with additions in green and removals in red. Switch between side-by-side and unified views, and use the options to ignore whitespace or letter case.
Side-by-side shows the original on the left and the changed version on the right, with matching lines aligned, which is easy to read. Unified diff shows one column with minus and plus signs, like the output of git diff. You can also copy or download the result as a unified diff or patch file.
Yes. You can ignore trailing spaces, ignore leading and trailing spaces and repeated spaces, or ignore all whitespace. You can also ignore uppercase and lowercase differences. This helps you to see only the real changes when the code was only re-indented or reformatted.
Yes. When a line was modified, the tool also highlights the words that changed inside the line, so you do not have to compare long lines by eye. You can turn this off in the settings.
All of them. The checker compares plain text line by line and does not depend on the language, so it works for JavaScript, PHP, Python, Java, C#, HTML, CSS, SQL, JSON, YAML, config files and ordinary text.
It is free, with no signup. The comparison runs completely in your browser, so your code is not uploaded to a server, saved or shared.
Compare code online, format and validate JSON, encode and decode Base64 or explain cron expressions in seconds. Explore free developer tools to compare, convert and debug your work in one place.
Explore All Developer Tools →