Compare Tool
text / compareType directly in either pane · J / K to jump between changes · arrows in the gutter copy a line across
Compare Tool
Compare two pieces of text or two files side by side and see exactly what changed. Differences are aligned line by line with line numbers, and the words that actually differ are highlighted within each changed line. You can edit either side in place, copy individual lines across with the arrows, undo anything you change your mind about, and export the result as a unified patch. Everything runs in your browser.
What you can do with it
- Merge changes across.The arrows beside each differing line copy it to the other side, so you can assemble a final version from two drafts without retyping anything. Every action can be undone.
- Edit either side.Double-click a line to change it and the comparison updates immediately. Useful for fixing a typo you spot while reviewing rather than switching back to an editor.
- Jump between changes.The up and down buttons move through the differences one at a time, which matters as soon as a file is longer than a screen. The strip down the right-hand side maps where the changes cluster.
- Collapse what has not changed.Long runs of identical lines fold into a single marker, so a small change in a large file is easy to find.
- Export a patch.The unified diff format is what
git applyandpatchconsume, so a comparison made here can be applied elsewhere.
How the comparison works
The tool uses Myers' difference algorithm, published in 1986 and the same approach behind git diff and most version control systems. Rather than comparing line one to line one and giving up when they differ, it finds the shortest sequence of insertions and deletions that turns one text into the other. That is why inserting a paragraph at the top shows as one insertion rather than making every subsequent line look changed.
Comparison runs at line level by default. Word and character modes are available for prose, where a rewritten sentence is more usefully described by which words moved than by which lines changed. Within a changed line, a second word-level pass marks the parts that actually differ.
The ignore options
- Case— treats "Total" and "total" as the same. Useful when comparing content that has been through a system which normalizes capitalisation.
- All whitespace— collapses runs of spaces and tabs, so re-indented code compares by content rather than by layout.
- Trailing whitespace— ignores spaces at the end of a line only. This is the setting for the common case of an editor that strips them on save and a file that never had them stripped.
- Blank lines— treats empty lines as equivalent, so a change in paragraph spacing does not read as a change in content.
Common uses
- Reviewing edits to a document.Paste the version you sent and the version that came back to see exactly what was changed.
- Comparing configuration between environments.Staging and production config files usually differ in a handful of values buried in hundreds of lines.
- Checking two API responses.Format both with the JSON formatter and sort their keys first, so the comparison shows real differences rather than reordered fields.
- Finding what a tool changed.Compare a file before and after a formatter, a migration, or a find-and-replace has run over it.
- Merging two drafts.Use the arrows to pull the best parts of each into one final version.
Things that trip people up
- Invisible whitespace differences.Two lines that look identical can differ by a trailing space or a tab versus spaces. If a line is marked as changed for no visible reason, this is almost always why — turn on the whitespace ignore options to confirm.
- Line endings.Windows uses a carriage return and a line feed where Unix uses only a line feed. This tool treats them as equivalent, but many others report every line as changed when the endings differ.
- Moved blocks read as delete plus insert.A section relocated within a file appears as removed in one place and added in another. That is inherent to how line-based comparison works, not a shortcoming of this tool specifically.
- Reformatting swamps real changes.If a file has been re-indented and edited in the same pass, ignore whitespace to see the substantive changes underneath.
- Very large inputs.Comparison happens in your browser, so files of several megabytes will be slow. Beyond roughly twenty thousand lines the tool falls back to a simpler whole-block replacement rather than stalling.
Frequently asked questions
Can I compare two files rather than pasting text?
Does editing here change my original files?
What is a unified patch?
git diff produces and what patch and git apply consume, so a comparison made here can be applied to a file elsewhere.