How to Compare Two Text Files and Find Differences

When two versions look almost identical, a line comparison shows exactly what changed without editing either original file.

Prepare the original and changed text

To compare two plain-text files, open each in a text editor, copy the original into the first pane of a diff viewer and the updated version into the second. The result highlights removed and added lines and leaves unchanged lines as context. Save copies of both originals before applying anything.

The tool compares text, not document formatting, binary files, spreadsheet formulas or file metadata. If you need byte-for-byte equality of large files, use a local file comparison or checksum instead.

Try the free Diff Viewer

Paste the two versions into the original and changed panes of our Diff Viewer. The line comparison updates as either input changes. Added and removed counts describe lines, not individual characters or words. The viewer uses a longest-common-subsequence comparison in the browser.

The current source compares at most the first 400 lines of each input and shows a limit notice if either input is longer. Never treat a truncated result as proof that the entire files match.

Try Diff Viewer

If the preview does not load, open Diff Viewer and customize it.

Read a worked diff

Imagine a small configuration file before and after a change. Original:

mode=light
font=serif
size=medium

Changed:

mode=dark
font=serif
size=medium
labels=on

The comparison should show one removed line and two added lines. The unchanged font and size lines provide context. A changed line is represented as one removal and one addition. This is the expected output from the example, not a claim that a live scan was performed.

− mode=light
+ mode=dark
  font=serif
  size=medium
+ labels=on

Check each altered line before deciding whether to carry the edit into your actual file.

Avoid misleading comparisons

Check whitespace, line breaks and encoding before drawing conclusions. Reformatting a file can produce many differences even if its meaning is unchanged. Conversely, a matching visible prefix does not prove a larger truncated file is identical. For JSON, compare consistently formatted copies; the line tool does not establish semantic equivalence.

For large files, binary files, proprietary source code or sensitive credentials, use a trusted local comparison utility. The widget comparison is browser-side, but the hosted page and its assets load over the network. Do not paste API keys, private configuration or personal data into an online tool.

Keep the comparison handy in Notion

Open customization, choose the theme, accent and size and copy the generated link to an /embed block. Give the two text panes enough width. The C shortcut copies the diff, S swaps the two inputs and X clears them when focus is outside text fields. A clipboard restriction can prevent copying. Use the original text files as your durable records rather than assuming the embed saves versions or applies patches.

For other developer helpers, see our developer widgets guide.

Common questions

Can it compare Word or PDF files?

It compares pasted plain text. It does not extract or compare document formatting or binary files.

Does it compare an entire very long text?

Only the first 400 lines per input in the current widget. A limit notice signals truncation; use a suitable local tool for larger files.

Will it edit my source file?

No. It displays line differences between the two inputs; decide and apply changes to separate copies yourself.