Tinker Tools

Text Diff Instantly

Compare two texts side by side and see the differences highlighted. All processing is done locally in your browser—your data never leaves your device.

Input
Original
Modified

No diff result yet

Enter texts above and click "Compare"

How it works

1. Paste Your Texts

Paste or type your original text on the left and the modified version on the right. Works with code, prose, or any plain text.

Local Processing

2. Choose Diff Type

Select between line, word, or character-level comparison depending on the granularity you need. Each mode highlights changes differently.

Multiple Modes

3. Review Changes

See added, removed, and unchanged content clearly highlighted with color coding. View statistics for a quick summary of the changes.

Clear Results

What is Text Diff?

A text diff tool compares two pieces of text and identifies exactly what changed between them. The output -- called a diff or a patch -- shows which lines were added, removed, or modified. This is the same fundamental operation that powers version control systems like Git, code review platforms, and document comparison features in word processors. The tool takes two inputs (often called the "original" and the "modified" or "left" and "right"), runs a comparison algorithm, and produces a structured representation of the differences. You see the changes highlighted visually: removed text in one color, added text in another, and unchanged context lines in between to help you orient yourself within the document.

The most widely used algorithm for computing diffs is the Myers diff algorithm, published by Eugene Myers in 1986. Myers' algorithm finds the shortest edit script -- the minimum number of insertions and deletions needed to transform the original text into the modified text. It works by modeling the problem as finding the shortest path through an edit graph, where moving right represents deleting a character from the original and moving down represents inserting a character from the modified text. Diagonal moves represent matching characters that require no edit. The algorithm runs in O(ND) time, where N is the total length of both inputs and D is the size of the minimum edit script. For inputs that are mostly similar -- which is the typical case in version control -- D is small and the algorithm is fast.

Under the hood, most diff algorithms rely on finding the Longest Common Subsequence -- or LCS -- between two sequences. The LCS is the longest sequence of elements that appears in both inputs in the same order, though not necessarily contiguously. Once you have the LCS, the diff is everything that is not part of it: elements in the original but not in the LCS are deletions, and elements in the modified text but not in the LCS are insertions. The classic dynamic programming solution for LCS runs in O(mn) time and space where m and n are the lengths of the two inputs. Myers' algorithm improves on this for the common case where the differences are small relative to the total size. Git uses a variant of Myers' algorithm by default, with an option to switch to a patience diff or histogram diff for cases where Myers produces confusing output.

Key Features and Benefits

  • Line-by-Line Comparison The default comparison mode treats each line as an atomic unit. A line is either unchanged, added, or removed. This is the same granularity used by git diff and the standard Unix diff command. Line-level comparison is fast, easy to read for structured content like source code, and produces output that maps directly to the unified diff format used by version control systems. If a single character on a line changes, the entire line shows as removed and re-added -- the next feature handles finer granularity.
  • Word-by-Word and Character-Level Diff When a line has only minor changes -- a typo fix, a renamed variable, a small wording tweak -- line-level diff marks the entire line as changed. Word-level and character-level diff modes zoom in further, highlighting exactly which words or characters differ within a changed line. This is critical for reviewing prose, documentation, and any content where changes are small relative to the line length. You immediately see that "recieve" was corrected to "receive" rather than having to scan two full lines looking for the difference.
  • Unified Diff Format Output The tool can produce output in unified diff format -- the standard used by git diff, patch files, and code review tools. Unified diff shows removed lines prefixed with a minus sign, added lines prefixed with a plus sign, and context lines prefixed with a space. Each changed section is preceded by a hunk header like @@ -10,7 +10,8 @@ that tells you the line numbers in both files. This format is machine-readable, which means you can save it as a .patch file and apply it with the patch command or git apply.
  • Side-by-Side and Inline Views Side-by-side view puts the original on the left and the modified version on the right, with matching lines aligned horizontally. This is the view most people find intuitive for code review. Inline view -- sometimes called unified view -- interleaves deletions and insertions in a single column, showing the old version of a line immediately followed by the new version. Inline view uses less horizontal space and works better on narrow screens or when the lines themselves are long. Switch between views depending on your screen size and the type of content you are comparing.
  • Whitespace and Case Sensitivity Options Control whether the comparison cares about trailing spaces, tab-versus-space differences, and blank line changes. When comparing code that was reformatted by an auto-formatter, ignoring whitespace changes lets you focus on the actual logic changes. Similarly, a case-insensitive mode helps when comparing text where capitalization differences are not meaningful -- for instance, comparing SQL queries where SELECT and select are functionally identical.
  • Merge Conflict Detection When two people edit the same section of a file independently, merging their changes produces a conflict. The diff tool can identify overlapping changes and present them in the standard conflict marker format used by Git: <<<<<<< marks the start of the first version, ======= separates the two versions, and >>>>>>> marks the end. Seeing the conflict clearly -- with both versions side by side and the surrounding context intact -- makes resolution faster and less error-prone than staring at raw conflict markers in a text editor.

How to Compare Two Texts

  1. 1

    Paste the Original Text

    Enter the original -- or older -- version of the text in the left input area. This can be anything: a source code file, a configuration file, a Markdown document, a database schema, or a plain-text email draft. The tool does not need to know the format; it operates on plain text lines regardless of the content type. If you are comparing file versions from Git, you can copy the content from a specific commit using git show commit:path and paste it here.

  2. 2

    Paste the Modified Text

    Enter the modified -- or newer -- version in the right input area. Make sure you are comparing the correct versions. A common mistake is pasting two copies of the same version and wondering why the diff is empty, or comparing the wrong branches of a document. If the texts are identical, the tool will tell you immediately -- no differences found. If you accidentally swapped the original and modified inputs, the diff will show additions as deletions and vice versa. The content is correct but the direction is reversed.

  3. 3

    Select the Comparison Mode

    Choose between line-level, word-level, or character-level comparison. For source code, line-level is almost always the right choice because code changes are typically expressed as whole-line additions and removals. For prose and documentation, word-level diff is more useful because it highlights the specific words that changed rather than flagging entire paragraphs. Character-level diff is specialized -- use it when you need to find single-character differences in dense text, like spotting the difference between a zero and an uppercase O in a serial number or API key.

  4. 4

    Review the Highlighted Differences

    Scan the output from top to bottom. Unchanged context lines anchor you in the document structure. Deleted lines -- highlighted in red or marked with a minus sign -- show what was removed. Added lines -- highlighted in green or marked with a plus sign -- show what was introduced. Modified lines appear as a deletion immediately followed by an insertion. Pay attention to the flow of changes: a block of deletions followed by a block of insertions at the same position usually means a section was rewritten. Scattered single-line changes throughout the document typically indicate small fixes like typo corrections or variable renames.

  5. 5

    Export or Apply the Diff

    Copy the diff output in unified format if you need to share it with a colleague or apply it as a patch. The unified diff can be saved as a .patch file and applied using standard tools: patch -p1 < changes.patch on Unix systems or git apply changes.patch in a Git repository. If you just need to confirm that two versions match your expectations, the visual comparison is enough -- close the tool and move on. For ongoing comparison needs, consider integrating diff functionality into your development workflow using git diff, diff in CI pipelines, or pre-commit hooks that flag unexpected changes.

Expert Tips for Text Comparison

Normalize your inputs before comparing them if you want to focus on meaningful changes. Auto-formatters, line-ending conversions (CRLF versus LF), trailing whitespace cleanup, and import sorting all produce diffs that are technically accurate but obscure the real changes. If you reformatted a 500-line file and also changed 3 lines of logic, the diff shows 500 changed lines and you have to hunt for the 3 that matter. The solution is to separate formatting changes from logic changes. Run the formatter in a separate commit, then make your logic changes in the next commit. When comparing files from different systems -- say, a Windows export and a Linux original -- normalize line endings first so every line does not show as changed. The diff tool's whitespace-ignore option helps, but it is better to fix the problem at the source.

Learn to read unified diff format fluently. It is the lingua franca of software development. The header lines starting with --- and +++ identify the two files. Each hunk starts with @@ -oldstart,oldcount +newstart,newcount @@ followed by an optional section heading. Lines starting with a space are context (unchanged). Lines starting with - are only in the original. Lines starting with + are only in the modified version. The count values tell you how many lines follow in each hunk for each file. If a hunk says @@ -45,7 +45,9 @@, the original has 7 lines starting at line 45 and the modified version has 9 lines at the same position -- meaning 2 lines were added. Being able to read this format in a terminal, in a code review tool, or in a patch file without needing a graphical viewer makes you faster at reviewing changes and resolving merge conflicts.

When dealing with merge conflicts, understand the three-way merge that caused them. Git does not simply compare two files -- it compares both modified versions against their common ancestor, called the merge base. A conflict occurs only when both branches changed the same lines differently. The conflict markers show you both versions, but they do not show the original. To see it, use git show :1:path/to/file to display the merge base version. With all three versions visible -- base, ours, and theirs -- you can understand the intent behind each change and merge them correctly. Many merge conflicts that look confusing with two-way comparison become obvious with three-way comparison. Tools like vimdiff, VS Code's merge editor, and IntelliJ's merge resolver all support three-way views for this reason.

Use diff as a debugging tool, not just a review tool. When a configuration file that worked yesterday breaks today, diff the current version against a known-good backup. When a SQL query returns different results after a schema migration, diff the before and after schemas. When a Docker image that built last week fails now, diff the Dockerfile and the dependency lock file. Diff tells you exactly what changed, and knowing what changed is often enough to identify why something broke. Keep dated backups or tag versions of critical files so you always have a reference point to compare against. In version-controlled projects, git diff HEAD~1 shows you everything that changed in the last commit -- start there when diagnosing recent regressions.

Related Tools

Text comparison works best when the inputs are normalized and consistently formatted. Format JSON with consistent indentation before diffing two API responses -- otherwise every key reordering and whitespace change shows up as noise. Normalize XML with proper indentation and attribute ordering so structural changes stand out from cosmetic ones. And when you are comparing Markdown documents, preview the rendered output in a Markdown viewer to confirm that the diff you see in the source actually produces the visual change you expect. These tools prepare your content for clean, meaningful comparisons.

Frequently Asked Questions

Recommended Tools