2026-10-20 · 8 min read
- diff
- text
- tooling
The diff page computes a semantic diff and prints it as HTML. diff_main builds the edit script, diff_cleanupSemantic may widen short edits, and diff_prettyHtml escapes a few characters and draws newlines as pilcrows. The colored ins and del tags are that HTML, styled by the page.
Count bytes from the two source boxes. Use the colored panel to see where the script says text was inserted or deleted.
Translate the pilcrow back to a newline
A newline inside the HTML is the entity ¶ followed by <br>. The pilcrow character is not in your file. A shared newline appears in an equal span. A newline that exists on only one side appears inside ins or del.
hello world, a newline, flashman, and a newline, compared with hello there, a newline, flashman!, and a newline, deletes world, inserts there, draws a pilcrow, keeps flashman, inserts !, and draws a final pilcrow. Identical inputs produce a single span. Two empty boxes produce no HTML at all.
- Normalize LF and CRLF before you look for a content edit.
- Treat a trailing newline as a real one-character difference.
- Read a blank result as two empty strings.
- Quote the source boxes in a review.
Keep carriage returns and markup visible
The printer escapes ampersands and angle brackets. It does not treat a carriage return as a newline. line1, LF, line2 compared with line1, CRLF, line2 shows an inserted CR and then the pilcrow for the LF. If you need those files to match, convert the newlines first.
<script> compared with <b> shows escaped brackets, with script deleted and b inserted. The input is not executed. A diff of HTML source is still a diff of text.
Expect semantic cleanup to widen words
The cat sat. against The dog sat. highlights cat and dog, not a single letter. aaaa against aaabaaa is the equal text aaa, an insertion of baa, and the equal text a. The cleanup prefers a boundary it likes over the shortest insert. A one-character bug can therefore light up several characters.
When the highlight is the thing you will paste into a ticket, paste the two sources as well. The highlight is a view of the script after cleanup.
Format structured text before you diff it
JSON that differs only by spacing will light up everywhere. Pretty-print both sides the same way first. A hash of each side tells you whether any byte differs, including a CR the panel makes easy to miss. A regex search can find \r in a paste that is too long to scan.
Use the diff tool for the view, the JSON formatter before comparing payloads, the hash tool for a byte check, and the regex tester to locate carriage returns. Say whether you compared the raw boxes or the pilcrow rendering.