The Code Codex
Theme

Text Compare (Diff)

Compare two texts side by side: different lines and characters, colour-coded changes, JSON with sorted keys and a .diff patch.

The link keeps what is on screen.

Both texts go into the share link (after the #, never sent to servers).

How to compare
Display
Highlight within lines by
JSON
“Sort keys” compares content regardless of field order: real differences still show up.
Normalization
Handy for lists, .env and imports: shows only what came in or went out.
Original (A)
Changed (B)

Paste both texts to compare.

How is it calculated?
Uses the Myers algorithm (the same as git diff) to find the shortest sequence of inserted and removed lines. Removed and inserted lines side by side become “changed”, and within them Myers runs again by character or word to highlight only what changed. Options normalize the text before comparing (whitespace, case, CRLF, line order, formatted JSON or sorted keys). Similarity = equal characters × 2 ÷ total characters of both texts.
See the code ↗

Processed in your browser; nothing is sent.

⌨️ Use from the terminal (JSON)

This tool also runs outside the site: the cli.js script uses the same logic as this page and returns the result as JSON. Parameters are the same as this page's URL — copy the command below with the values on screen.

Deno
deno run -q "https://thecodecodex.com/cli.js?tool=diff"
Node.js / Bun
curl -s https://thecodecodex.com/cli.js | node --input-type=module - diff a=…
ParameterDescriptionDefault
atexto original—
btexto alterado—
grandestaque dentro da linha: char | wordchar
jsonoff | format | sortKeysoff
ws1 = ignora espaços extras0
case1 = ignora maiúsculas0
eol0 = diferencia CRLF de LF1
sort1 = ordena as linhas antes0

Requires Deno, Node.js or Bun. With Deno the script runs with no permissions: it cannot read files or access the network. Central Bank indicators are from the day the site was published.

More in Development