Text Diff — Compare Two Texts Line by Line

Compare two texts line by line with a side-by-side view and a git-style unified diff, powered by a fast LCS algorithm. Runs entirely in your browser.

Inputs

How it works

About Text Diff

A good diff shows not just that two texts differ, but exactly where and how. Line-based comparison is the right granularity for configuration files, server logs, generated code, or any change review: a single moved block reads clearly as removed-plus-added instead of a wall of red.

Use this tool to sanity-check config changes before deploying, to review what a teammate actually changed in a pasted snippet, or to build a patch you can paste into a PR description. Because the comparison happens on your machine, even confidential log excerpts or private configs can be diffed safely.

The alignment algorithm and its budget

Lines from both inputs are aligned with a longest-common-subsequence dynamic program, which finds a minimal set of insertions and deletions rather than reporting every shifted line as changed. The table stores only two rolling rows of `Uint32Array`, and the per-cell move direction is packed two bits per cell into a single `Uint8Array` — about a quarter byte per cell, which is what makes the full table affordable in a browser tab.

Above roughly five thousand lines on either side, or a product of line counts exceeding thirty million, the full table is abandoned for a positional fallback that pairs line *n* of one input with line *n* of the other. That fallback is linear and never blocks, but its output degrades sharply: a single inserted line near the top makes every line beneath it appear modified.

Reading the two views

The side-by-side view pairs each run of consecutive deletions with the following run of insertions, so replacing two lines shows as two rows with both cells filled and both sides numbered independently. Those numbers count only that side's lines, which makes them usable as positions in the original file rather than as diff offsets.

The unified output follows the git format with three lines of context and `@@` hunk headers carrying computed line numbers and counts, suitable for pasting into a pull request. Overlapping change runs are merged into a single hunk rather than emitted twice. Headers are labelled `Original` and `Changed` instead of carrying file paths, and identical inputs produce an explicit no-differences message rather than an empty view.

Comparison semantics and edge cases

Comparison is exact string equality on the split lines, with no whitespace normalisation. A file whose line endings changed from LF to CRLF reports every line as modified, because each line retains a trailing carriage return after splitting on ` ` — normalise the endings first if that is the only difference between the two versions.

There is no trailing-newline marker, so a file that gained or lost its final newline shows an extra empty added or removed line at the end. The `Swap` button re-runs the comparison immediately, which is the quickest way to check a change in the opposite direction. For structured payloads, the JSON Diff tool reports paths and value changes instead of raw lines.

Frequently Asked Questions

How do I compare two text files?
Paste the original text in the left panel and the modified version in the right panel. The tool highlights all added, removed, and changed lines in red and green respectively. A unified diff view is also available.
Can I compare more than two versions?
The current tool compares two versions side by side. For multi-version comparison, use the Compare button to swap the left and right panels after making edits.
Is my data sent to a server?
No. Every tool on jsonversal runs entirely in your browser using the Web Crypto API, File API, and Clipboard API. Nothing is ever uploaded — not even the JSON you paste in.
Do I need an account or API key?
No signup, no email, no API key. All tools are free to use with no signup required.
Can I use these tools offline?
Yes. Once the page loads, all tools work offline. There are no external API calls or CDN dependencies at runtime.
🔒
Your data never leaves your device

All processing happens in your browser. No uploads, no tracking, no servers. Your API keys, configs, and private payloads stay private — 100% client-side.

esc
↑↓ navigate ↵ open esc close