Inline Text Diff Viewer

Compare two strings character-by-character with inline highlights

See exactly what changed between two pieces of text. A character-level diff highlights additions in green and deletions in red inline, using a longest-common-subsequence algorithm for minimal edits. Runs in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What algorithm does the diff use?

It computes the longest common subsequence (LCS) of the two strings with a dynamic-programming table, then walks that table to produce the smallest sequence of insertions and deletions. This is the same core idea behind classic diff tools.

When two strings look almost identical, spotting the one character that differs by eye is hard. This viewer compares them character by character and highlights the exact additions and deletions inline, so the change jumps out immediately.

How it works

The tool builds a longest-common-subsequence table over the two strings. The LCS is the longest run of characters that appears in both, in order, and everything outside it is an edit:

dp[i][j] = length of LCS of original[i..] and changed[j..]

Walking the table from the start, when characters match they are emitted as unchanged; otherwise the tool deletes from the original or inserts from the changed text, whichever keeps the edit minimal. Adjacent edits of the same kind are merged into single highlighted runs.

What the colour coding means

  • Green highlight — characters present in the changed text but not the original (additions).
  • Red strikethrough — characters present in the original but not the changed text (removals).
  • Plain text — characters that are identical in both strings and in the same position relative to the LCS.

The counter at the top tallies the number of characters added and removed so you get an immediate size signal alongside the visual diff.

The kinds of differences character mode catches best

Invisible whitespace changes

Copying text from a PDF, email, or web page often introduces non-breaking spaces ( ), zero-width joiners, or extra ASCII spaces that look identical on screen. When you paste the “same” string into both boxes and the diff shows a red-then-green run at that position, you have found an invisible character difference. Word-level diff tools typically hide this because they treat the whole word as one token.

Transposed or substituted characters

A valid-looking API key with one wrong digit, an ISBN with a digit swapped, or a credit-card number where two adjacent digits were transposed — these all produce exactly one character diff that would be invisible in a side-by-side reading. The inline character view makes the deviation obvious.

Curly versus straight quotes and dashes

Content migrating between rich-text editors and plain-text systems frequently introduces substitutions: " becomes " or ", ' becomes ' or ', and -- becomes . A spell-checker won’t flag these; a character diff will.

Worked example

Original: Authorization: Bearer abc123XYZ Changed: Authorization: Bearer abc123xyz

The diff highlights X, Y, Z as red (removed) and x, y, z as green (added) — everything else is unchanged. The header value differs only in casing of the last three characters, which would have caused a silent authentication failure.

Tips and notes

  • Because whitespace is compared too, you can verify that two config snippets are byte-identical — a trailing space or an extra newline will appear as a red character at the end.
  • For whole documents, this character view can be slow on very long inputs. Split the document into the paragraph or line you care about before pasting.
  • When diffing code identifiers or function names, character mode is more useful than word mode, which treats getUserId and getuserId as two entirely different tokens and can’t show you that only the I changed.