Starting points for your own code. Run them in the environment shown below.
Node.js 22+ · ES module (.mjs)
Current inputs apply only to fields used by the example. Selected files are not embedded.
Install dependencies
npm install diff
import { diffLines } from "diff";
const before = "hello\nworld\n";
const after = "hello\ntools\n";
console.log(diffLines(before, after));
Put it to work
Paste configuration versions to inspect added and removed lines.
Details that matter
Format and meaning
Line mode suits configuration files; word mode suits prose edits.
Using it correctly
Ignoring whitespace normalizes repeated and trailing whitespace before comparing.
Supported scope and limits
100 KB per text; maximum calculation time 1 second
Split inputs that exceed the limit. If a format or algorithm is unsupported, choose a tool that matches your requirements instead of silently changing the format.