Text Diff Online — Side-by-Side Comparison

Compare two pieces of text line by line. Added, removed, and unchanged lines are highlighted side-by-side using a Myers-style LCS diff. 100% in your browser.

Paste text in both panels to see the diff.

What is a text diff?

A text diff finds the smallest set of insertions and deletions that turn one text into another. The result is the same edit script you see in a code review or git log — added lines highlighted, removed lines marked, unchanged context kept for orientation.

The OpenFormatter text diff uses an LCS-based algorithm (the same family as Myers diff) to produce a minimal, line-aligned comparison. It runs in your browser, so contracts, code, and proprietary configs never leave the device. Add and delete counts are summarised at the top and an "Identical" badge appears when the two inputs match exactly.

How to diff two texts — 4 steps

  1. Paste the original. Drop the "before" text into the left panel — a config file, a paragraph, a JSON document, anything line-based.
  2. Paste the changed version. Drop the "after" text into the right panel.
  3. Scan the result. Red rows are deletions, green rows are additions, neutral rows are unchanged context. The header shows +/-/= counts.
  4. Swap or clear. Use Swap to flip the comparison direction; Clear to wipe both panels and start fresh.

Sample input and output

Left:                          Right:
apiVersion: v1                 apiVersion: v1
kind: Service                  kind: Service
metadata:                      metadata:
  name: web                      name: web
                                 namespace: production       <- added
spec:                          spec:
  ports:                         ports:
    - port: 80                     - port: 8080              <- changed
                                     targetPort: 8080         <- added
  selector:                      selector:
    app: web                       app: web

Counts: +3 added · -1 removed · =8 unchanged

The diff aligns common context lines so changes appear in their natural place — exactly how you would read a pull request.

Side-by-Side Layout

Both versions sit next to each other with line numbers and aligned context — the easiest format for reading at a glance.

LCS / Myers Style

The diff finds the longest common subsequence and produces a minimal-edit script — the same approach used by git, hg, and most code-review tools.

Client-Side Only

Both texts and the diff computation stay in your browser. Safe for source code, NDAs, contracts, and internal manifests.

Fast on Big Inputs

Tens of thousands of lines diff in milliseconds. No upload, no rate limits, no waiting on a server round-trip.

Common use cases

  • check_circleReviewing config-file changes before applying them in production
  • check_circleComparing two API responses to spot drift between environments
  • check_circleAuditing two versions of a contract or policy document for redlines
  • check_circleSpotting accidental edits in copy/paste workflows
  • check_circleComparing two SQL queries or stored procedures during refactoring
  • check_circleDiffing two JSON documents (pretty-print first for best results)
  • check_circleVerifying a build artifact matches the expected output line-for-line
  • check_circleCross-checking translations against the source text

Diff modes — line vs word vs character

ModeBest forTrade-off
LineCode, configs, JSON, YAMLMisses sub-line edits
WordProse and editorial reviewPunctuation noise
CharacterTypo fixes, hashes, IDsHard to read on big texts

This tool runs the line-level diff that handles 95% of real-world comparison work. For prose-heavy redlines a dedicated word-level diff is more readable.

Diffing structured data?

Pretty-print JSON or YAML first so structural changes show up as line changes rather than as one giant blob.

Frequently Asked Questions

How does the text diff work?

The diff splits both inputs into lines, then finds the longest common subsequence (LCS) using dynamic programming. Lines in the LCS are unchanged. Lines from the left side that are not in the LCS are deletions. Lines from the right side that are not in the LCS are additions. The result is rendered side-by-side so you can scan for changes by eye.

Is this a Myers diff?

It is the same family of algorithms — both Myers and the simpler LCS-DP approach produce a minimal-edit-script diff. For tens of thousands of lines this implementation runs in milliseconds in the browser. For very large inputs (hundreds of thousands of lines) you would want a true Myers O(ND) implementation; for the typical config-file or paragraph use case the difference is invisible.

Why are some unchanged lines shown twice?

They are not — unchanged lines render once on each side aligned at the same row. What can look like duplication is the side-by-side layout: the row pairs the left and right copies of the same line so you see context on both panels in sync.

Can it diff JSON, YAML, or code?

Yes — the diff is line-based and language-agnostic. Pretty-print your JSON or YAML first (using the OpenFormatter formatters) so structural changes show up as line changes rather than as a single huge changed line. For code, paste the raw source and the algorithm will line-align matching lines automatically.

What is the difference between line diff, word diff, and char diff?

A line diff treats each line as the smallest unit. A word diff splits each line into tokens and shows which words changed. A character diff is finer still — useful for showing typo fixes. Line diff is the right default for code and config; word/character diffs help when comparing prose where every line is long.

Are my texts uploaded?

No. Both inputs and the diff computation stay entirely in the browser. Open DevTools → Network — clicking around in the diff produces zero requests. Safe for proprietary code, contracts, and internal documents.

Why are my whitespace-only differences highlighted?

Whitespace counts. A line ending with two spaces is a different line from one ending with three. To ignore whitespace, normalise both inputs first — collapse runs of whitespace to single spaces, or strip trailing whitespace before pasting.

Can I diff more than two texts?

This tool compares two at a time. For three-way merges (you, them, base) use a dedicated merge tool like git mergetool, kdiff3, or VS Code's built-in three-way merge view. Pairwise diff is sufficient for the vast majority of comparison tasks.

Text Diff Online — Free Side-by-Side Text Comparison Tool