Text diff

Compare two texts or two JSON documents online, side by side as you type: changed lines are highlighted, and inside each one exactly the characters that differ.

» copies a change to the right, « to the left. In JSON mode, merging rewrites both sides in the compared (formatted) form.

How to use it

Paste the original text on the left and the changed one on the right: the differences appear as you type. Lines only on the left are red, lines only on the right are green, and on lines changed in place the exact characters that differ are highlighted. Long stretches of unchanged lines are folded: click them to show them. Pick JSON to compare two JSON documents by content.

Frequently asked questions

How does the JSON mode work?

Both documents are checked and pretty-printed the same way before they are compared, so indentation, spaces and line breaks do not count, only the content does. With “ignore key order” the keys are sorted at every level, so {"a":1,"b":2} and {"b":2,"a":1} are identical. If one side is not valid JSON, you see where it breaks.

Why are some lines shown as changed and others as removed and added?

Inside each block of differences, every removed line is paired with the added line that looks most like it, keeping the order: each pair is shown on the same row as a changed line, with the differing characters marked. Lines with nothing similar on the other side are shown alone, as removed (red) or added (green).

Do line endings or trailing spaces count?

Windows (CRLF) and Unix (LF) line endings are treated as the same, so a file saved on another system does not show every line as changed. Spaces and tabs do count, also at the end of a line: they are highlighted like any other character.

How do I merge changes from one side to the other?

Every block of changes has two arrows in the middle column, as in an IDE: » copies the left version of that block to the right, « the right version to the left. The diff updates at once, and “Undo merge” takes back the merges one at a time until you type again. In JSON mode both sides are rewritten in the formatted form that was compared, with sorted keys if “ignore key order” is on.