Skip to content

How to compare two text files online

A practical guide to finding every difference between two versions of a document, what the comparison settings actually do, and how to keep confidential text private while you do it.

The short answer

To compare two text files online, paste the original into the left panel of a diff tool and the revised version into the right, then run the comparison. The tool aligns matching lines and marks what was added, removed or edited. Choose word precision for prose and character precision for code, and enable the ignore-whitespace option if one version has been reformatted. If the content is confidential, use a tool that runs the comparison in your browser rather than uploading the files to a server.

The five steps

  1. 1

    Open a comparison tool

    Any browser-based diff tool will do. Prefer one that states it works client-side if your content is at all sensitive.

  2. 2

    Add the original version

    Paste the earlier version into the left panel, or drag the file onto it. The left side is conventionally treated as the 'before'.

  3. 3

    Add the revised version

    Paste the newer version into the right panel. Keeping this order means additions read as green and removals as red.

  4. 4

    Choose your comparison settings

    Pick line, word or character precision, then decide whether case, whitespace, punctuation or blank lines should count as differences.

  5. 5

    Review and export

    Step through each change in order, then copy the result, download a report or patch, or print it to PDF.

Open the comparison tool

How a diff tool actually works

A good comparison tool does not check line one against line one, line two against line two, and so on. That approach breaks the moment a line is inserted or deleted: everything after the insertion shifts by one position and gets reported as changed, even though it is untouched.

Instead, a diff algorithm searches for the longest sequence of lines the two documents have in common, then describes the remainder as the shortest list of insertions and deletions that turns one into the other. This is the approach used by version control systems, and it is why inserting a paragraph at the top of a document produces one reported addition rather than hundreds of reported edits.

Once lines are aligned, a second pass compares the contents of lines that were matched but not identical, which is what lets a tool highlight the individual word or character that changed inside an otherwise unchanged sentence.

Choosing the right comparison settings

Precision: line, word or character

Line precision marks an entire line as changed if anything in it differs. It is the fastest to scan and suits structured data and generated files where you mainly want to know which records moved.

Word precision highlights only the words that differ within a line. This is the right default for prose, proofreading and contract review, because it shows the substance of an edit rather than just its location.

Character precision isolates individual characters. Use it to catch transposed digits in a reference number, a changed operator in code, or a swapped letter in a name — the differences that are easy to read straight past.

When to ignore whitespace

Turn whitespace handling on when one version has been through a formatter, exported from a different tool, or re-indented. Leave it off for code in whitespace-sensitive languages, and for any file where alignment carries meaning.

When to ignore case and punctuation

Ignoring case helps when comparing identifiers, headings or data from systems that disagree about capitalisation. Ignoring punctuation is useful for comparing transcripts or translations, where you care about wording rather than commas — but avoid it for code and structured data, where punctuation is syntax.

When to sort lines first

Sorting both sides before comparing answers a different question: not “what changed and where” but “which entries exist in one list and not the other”. Use it for unordered lists, exported records and configuration keys. Do not use it when sequence matters.

Keeping sensitive text private

This is the part most guides skip. Many online comparison tools post both blocks of text to a server, where they are processed and sometimes retained. For a shopping list that is irrelevant. For a contract under negotiation, a production configuration file, an unreleased announcement or anything containing credentials or personal data, it matters a great deal.

Two checks tell you which kind of tool you are using:

  • Open your browser’s developer tools, switch to the network tab, and run a comparison. A client-side tool makes no request when you press compare.
  • Load the page, disconnect from the internet, then compare. A client-side tool keeps working; a server-based one cannot.

This tool passes both checks: the comparison is performed by JavaScript in your browser, and no text is transmitted or stored. Even the share links carry their content in the URL fragment, the portion after the # symbol, which browsers do not send to servers.

Common problems and how to fix them

Everything shows as changed

Usually a line-ending or encoding mismatch, or one side has been reformatted. Enable the whitespace options first. For JSON, format both sides before comparing.

The tool says the files differ but they look identical

Look for trailing spaces, a missing final newline, non-breaking spaces pasted from a word processor, or curly quotes on one side and straight quotes on the other. Character precision will point straight at it.

The result is too long to read

Collapse the unchanged sections so only the differences and a few lines of surrounding context remain, then step through the changes one at a time rather than scrolling.

Frequently asked questions

How do I compare two text files online?

Paste your original text into the left panel and the revised text into the right panel, then press Compare. Every added, removed and modified line is highlighted side by side, with changed words picked out inside each line. You can also drag a file straight onto either panel instead of pasting.

Is it safe to compare confidential or sensitive text here?

Yes. Text Compare runs the entire comparison in your browser using JavaScript, so the text you paste is never uploaded, transmitted or stored on any server, and no account is required. You can confirm this by disconnecting from the internet after the page has loaded: the comparison keeps working offline. The site does load analytics and advertising, which measure page visits and fund keeping the tool free, but those services never receive the content you compare, and session replay is explicitly blocked from the editors and results.

What is the difference between line, word and character comparison?

Line precision marks a whole line as changed if anything in it differs, which is best for code and structured data. Word precision highlights only the words that changed inside a line, which is best for prose and proofreading. Character precision pinpoints individual characters, which is best for catching typos, transposed digits and subtle formatting changes.

Can I ignore whitespace, capitalisation or blank lines?

Yes. The comparison settings let you ignore case, collapse repeated whitespace, trim leading and trailing spaces, skip blank lines, ignore punctuation, and sort lines before comparing. Sorting is useful when you need to compare two unordered lists and only care about which entries exist.

Is there a file size or usage limit?

There is no account limit and no daily cap. The practical ceiling is your device's memory, since everything runs locally. Documents of several thousand lines compare in a few milliseconds, and unchanged sections are collapsed automatically so large results stay readable.

Can I share a comparison with someone else?

Yes, and it does not require an account. The Share button compresses both texts into the link's fragment, the part after the # symbol. Browsers never send that fragment to a web server, so the link reconstructs the comparison entirely on the recipient's device while still keeping the content off our infrastructure.

Does this work for code, JSON and CSV files?

Yes. Dedicated modes are available for code, JSON and CSV. The JSON mode can pretty-print both sides first so that formatting-only differences disappear and you see genuine key and value changes, and the CSV mode can sort rows so reordered exports still line up.

How do I export or save the comparison result?

You can copy the result to your clipboard, download it as a plain text report, download a standard unified diff patch file that Git and other tools understand, or use Print to save a clean, colour-accurate PDF.