Skip to content
ToolkitHub

Diffchecker

Compare two text blocks

Guide

Comparing text and code with a diff checker

By Logappradeep · ServiceNow developer

A diff shows exactly what changed between two versions of a text. Instead of reading both versions and hoping to spot the difference, you see removed lines, added lines and changed characters highlighted. Diffs are at the heart of version control and code review, but they are just as handy for comparing configuration files, API responses, contracts, translations or two exports of the same report.

How diff algorithms work

Finding the differences between two texts is a classic computer science problem. Most diff tools look for the longest common subsequence, the largest set of lines that appear in both versions in the same order. Everything outside that common backbone is reported as a deletion from the left side or an insertion on the right. Algorithms in the family of Eugene Myers' 1986 O(ND) algorithm, the approach behind Git's default diff, solve this efficiently and prefer the smallest set of edits. Once lines are paired up, a second pass highlights the individual characters that changed within each modified line.

What this diff checker offers

The tool is built on the Monaco diff editor, the editor component used in Visual Studio Code. Paste or type into the Original (left) and Modified (right) panes, both of which are editable, or load a file into either side. Choose a language such as JSON, JavaScript, TypeScript, Python, SQL, YAML or Markdown for syntax highlighting. Switch between Split view, which shows the versions side by side, and Inline view, which interleaves them in one column. Arrow buttons next to each change copy that block from one side to the other, which lets you merge selectively. A summary shows additions, deletions, unchanged lines and an approximate similarity percentage, and you can swap sides, go full screen or download a simple patch file.

Practical uses

  • Spotting what changed between two versions of a config file or .env template.
  • Comparing API responses from staging and production.
  • Reviewing edits to a contract, policy or documentation page.
  • Checking a generated file against the expected output in a test.

Pitfalls

Whitespace and line endings. Files from Windows use \r\n line endings and files from macOS or Linux use \n; trailing spaces and tabs versus spaces also count as changes. Turn on Ignore Spaces to skip leading and trailing whitespace differences when they are not meaningful.

Reformatted data. If one JSON file is minified and the other pretty-printed, or keys are in a different order, nearly every line differs even though the data is the same. Format both sides consistently first, or use a structural JSON diff.

Similarity is approximate. The percentage compares sets of lines, so moved or duplicated lines can make it look higher or lower than the visual diff suggests.

Comparison runs in your browser; nothing is uploaded. Both texts and your view settings are saved in local storage, so clear the workspace when you compare sensitive material on a shared computer.

Frequently asked questions

Is my text uploaded when I compare files?

No. The comparison runs in your browser. Both texts are saved in local storage so they survive a reload, so clear them on shared machines.

Why does every line show as changed?

This usually means different line endings, indentation or formatting. Turn on Ignore Spaces, or reformat both sides the same way before comparing.

What is the difference between split and inline view?

Split view shows the two versions side by side. Inline view shows them in one column, with removed lines followed by added lines.

Can I merge changes from one side to the other?

Yes. Use the arrow buttons beside each change to copy that block from left to right or from right to left.