Online Diff Checker
Compare two versions of text or code and see the differences highlighted.
No Diff to Display
Enter text in both panels above to see the differences highlighted. You can compare code, text, or any content.
Split view: Side-by-side comparison of original and modified text.
Inline view: Changes shown in sequence with + and - markers.
Unified view: Combined view with line numbers from both versions.
Guide: How to compare two text files, in the browser, VS Code or the terminal
Compare code and text online
You have two versions of the same file, say a function before and after a refactor or a config file copied from two servers, and you need to know what changed. Paste both into this diff checker and it marks every line as removed, added or unchanged.
The comparison is done by the open-source jsdiff library, which finds the smallest set of additions and removals that turns the original into the modified version. It runs in your browser and recomputes the result on every keystroke, so there is no compare button and no upload.
Features
- Compares in your browser with no upload
- Line, word or character comparison
- Split view with original and modified side by side
- Inline and Unified single-column views
- Load either side from a text or code file
- Case-insensitive search across the result
- Toggle wrapping for long lines
- Copy the diff or download it as diff.txt
How to check the differences between two files
- 1
Add the original version
Paste the older text or code into the Original box, or click the upload icon in its header to load a file from your device.
- 2
Add the modified version
Paste the newer version into the Modified box, or upload it. The Diff Result panel appears and updates as you type, with no compare button to press.
- 3
Choose how finely to compare
Use the Compare menu to pick Lines (the default), Words or Characters.
- 4
Pick a view
Switch between Split, Inline and Unified, and turn Wrap off if you would rather scroll long lines sideways than wrap them.
- 5
Search, copy or download
Press Find (or Ctrl+F) to search the result, then use the copy or download buttons in the Diff Result header to keep a text copy. Swap exchanges the two boxes and Clear empties both.
Keyboard shortcuts
- Ctrl / Cmd + F
- Open Find in the diff
- Esc
- Close Find, or exit fullscreen
Drag the handle between the input boxes and the Diff Result panel to give either more room, or use the fullscreen button at the end of the toolbar.
Worked example: reading a code diff
Say a teammate changed one line of a JavaScript function to use a template literal. Paste the two versions into the boxes:
Original
function greet(name) {
const msg = "Hello, " + name;
console.log(msg);
return msg;
}Modified
function greet(name) {
const msg = `Hello, ${name}!`;
console.log(msg);
return msg;
}With Compare set to Lines, the header of the Diff Result panel reads 1 added, 1 removed, 4 unchanged and 2 changes. The tool reports the edited line as one removal plus one addition. A line diff only checks whether each whole line still exists, so it cannot describe an edit inside a line.
In Split view, line 2 appears in red on the Original side and its replacement in green on the Modified side, on the same row, so the old and new versions sit next to each other. Lines 1 and 3 to 5 are unchanged and stay uncoloured on both sides. In Unified view the same information is in one column. The removed line comes first, then the added line, and both are numbered 2. A removed line keeps its number from the original and an added line takes its number from the modified version. The copy button gives you this text:
function greet(name) {
- const msg = "Hello, " + name;
+ const msg = `Hello, ${name}!`;
console.log(msg);
return msg;
}To see which characters inside that line changed, paste just the two versions of line 2 and switch Compare to Characters. The result then lists each unchanged, removed and added run of characters on its own row, such as the removed " and the added `.
Lines, Words or Characters?
Lines is the default and the right choice for code, config files, CSV rows and most documents. Git also compares line by line by default. In this mode the counts in the header are numbers of lines.
Words and Characters are for short pieces of text where you want the exact edit, such as a changed word in a sentence or one digit in an ID. The tool puts each changed fragment on its own row rather than highlighting it inside the line. On a long file these modes break the text into many small rows, and Lines is easier to read. In both modes the added, removed and unchanged counts are numbers of characters.
Split, Inline or Unified view?
Split (the default) shows Original on the left and Modified on the right, each with its own line numbers. Removed and added lines are paired on the same row, and blank spacer rows keep the rest aligned.
Unified puts everything in one column with a line number on each row, in the style of a Git diff. It suits narrow screens and long lines.
Inline is the same single column without line numbers, for when you only want to read the change list.
Your text stays on your device
There is no upload step. JavaScript running in your browser tab compares the pasted text and reads any file you load, so private code or configuration never leaves your device.
The page sends anonymous usage events, such as a press of Swap or Clear, so we can see whether the tool is used. The text you compare is never sent.
Tips for a cleaner diff
- Run both versions through the same formatter first, such as the JSON formatter, so reformatting does not hide the real changes.
- If one box ends with a line break and the other does not, the last line shows as changed. Make the endings match.
- Pasted the versions the wrong way round? Press Swap instead of pasting again.
- Use Find to jump to a function name or key in a long diff. The search bar shows how many rows match, and its up and down arrows step through them.
Limitations
- It compares two pieces of plain text. It cannot compare folders, several files at once, or binary documents such as Word, PDF or images.
- There is no option to ignore whitespace, indentation or letter case. Every difference counts, apart from line-ending style (CRLF, CR and LF are treated the same).
- There is no syntax highlighting. The only colours are green for added and red for removed.
- Moved blocks are not detected. A block cut from one place and pasted elsewhere shows as a removal and a separate addition.
- Words and Characters modes list each changed fragment on its own row instead of highlighting it within the line.
- Copied and downloaded diffs are a readable text list, not a unified patch that git apply can use.
- No size limit is set, but the whole comparison runs in your tab, so very large inputs can make the page slow.
Frequently asked questions
How do I compare two pieces of code online?
Paste the older version into the Original box and the newer version into the Modified box, or load each one with the upload button in the box's header. The Diff Result panel updates as you type: removed lines are red with a minus sign, added lines are green with a plus sign, and unchanged lines stay plain.
How do I check the differences between two texts?
The same way as code. Paste both versions, keep Compare set to Lines for documents and lists, and read the counts at the top of the Diff Result panel to see how many lines were added, removed and left unchanged. For a single sentence or a short value, switch Compare to Words or Characters to pin down exactly what changed.
Can I compare JavaScript, Python or other code files?
Yes. The checker compares plain text, so any language works. The upload button offers common text and code files such as .js, .ts, .jsx, .tsx, .py, .go, .rs, .java, .c, .cpp, .h, .html, .css, .json, .xml, .yaml, .md and .txt. The tool shows code in a monospaced font but does not add syntax highlighting.
Is my text uploaded to a server?
No. JavaScript in your browser tab runs the comparison and reads any file you load from your device. The page records anonymous usage events, such as a press of the Swap or Clear button, but never the text you compare.
Can I ignore whitespace or letter case?
No. There are no ignore options, so changed indentation, trailing spaces and capitalisation all count as differences. Line endings are the one exception. The tool converts Windows (CRLF) and old Mac (CR) line breaks to plain LF before comparing, so a file saved on a different operating system does not show every line as changed.
Can I save the diff or use it as a patch?
You can copy the result to the clipboard or download it as diff.txt with the buttons in the Diff Result header. The tool starts each line with +, - or a space. The result is a readable change list without file names or @@ hunk headers, so tools such as git apply or patch cannot use it.
Why is the last line marked as changed when it looks identical?
One version probably ends with a line break and the other does not. In Lines mode the diff treats a line with a trailing newline and the same line without one as different, so the last line shows as removed and added again. Add or remove the final empty line in one box and it will match.
Is this online diff checker free?
Yes. It is free, needs no sign-up and nothing to install. Open the page, paste two versions and the differences appear straight away.
Related tools
JSON Formatter
Format JSON online in your browser. Paste or upload JSON to tidy it with 2 or 4 space indents, find syntax errors, minify it or browse it as a collapsible tree.
JavaScript to JSON
Convert JavaScript object literals to valid JSON
JSON Merge
Merge two JSON objects online with a deep or shallow strategy and choose how arrays combine. Useful for config files and API responses. Free, no signup.