2026-10-20 · 6 min read · Rahul Chitturi
- diff
- text
- debugging
The diff page runs diff_main, then diff_cleanupSemantic, then diff_prettyHtml. What you see is HTML, not a unified patch. Inserted text is an ins element and deleted text is a del element. The page styles those tags. It does not offer a button that copies the raw edit script.
A newline and a one-character edit can both look larger than the bytes you changed. The printer draws a pilcrow for each newline, and semantic cleanup is allowed to widen a small replacement to a word.
A newline is a pilcrow in the HTML
In an equal span, a newline is written as the characters ¶<br>. The pilcrow is the display of the line break. It is not a character that was in the file. hello world plus a newline plus flashman plus a newline, compared with hello there plus a newline plus flashman! plus a newline, shows world deleted, there inserted, a pilcrow, flashman, an inserted exclamation mark, and a final pilcrow.
Two identical strings produce one span and no ins or del. Two empty strings produce empty HTML, so the panel looks blank. A trailing newline on only one side is a real one-character edit plus a pilcrow, which is why a file that gained a final newline looks busier than a one-byte change.
- Read ¶<br> as a newline that both sides share or one side has.
- Compare the source boxes, not the pilcrows, when you count bytes.
- Treat a blank panel as two empty strings.
- Keep a trailing newline in the note if only one side has it.
A carriage return is not a newline here
The pretty printer escapes &, <, and >, and it turns \n into a pilcrow. It leaves \r in the HTML. line1 plus LF plus line2, compared with line1 plus CRLF plus line2, shows an inserted carriage return and then the pilcrow for the LF. A Windows file and a Unix file of the same lines will not diff as equal.
<script> compared with <b> shows an escaped less-than, script deleted, b inserted, and an escaped greater-than. The angle brackets are text. The page is not running the string as HTML from the input.
Semantic cleanup widens the highlight
The cat sat. compared with The dog sat. highlights the whole word cat against dog. aaaa compared with aaabaaa is not a single inserted b. The HTML is the span aaa, an insertion of baa, and a span a. Quote the two source strings in the ticket when the highlight is wider than the edit you intended.
Use the diff tool after both sides have the same newline style, the JSON formatter before you diff payloads, the hash tool when you need to know that the bytes differ at all, and the regex tester to find a CR in a larger paste. The pilcrow is a display. The hash is the bytes.