Text & Code Diff

Paste two versions of text or code to instantly see additions, deletions, and unchanged lines with line numbers. Works with any language or format.

+2
Added
-2
Removed
2
Same

Diff Output

2 additions, 2 deletions, 2 unchanged

1function greet(name) {
2 console.log('Hello, ' + name);
1+function greet(name, title) {
2+ console.log(`Hello, ${title} ${name}`);
33 return true;
44 }

Relevant tools

Browse all →

Related developer and text tools.

How to use the text and code diff tool

Paste the original version of your text or code into the left panel (A) and the modified version into the right panel (B). The diff output updates instantly, showing you exactly which lines were added, removed, or left unchanged. Each line in the output is prefixed with a green plus sign for additions, a red minus sign for deletions, or a blank space for unchanged lines. Line numbers from both inputs are displayed in columns on the left for easy reference.

Use the "Ignore whitespace" option when comparing code that has been reformatted or when indentation differences don't matter. This trims leading and trailing spaces and collapses multiple spaces into one before comparing. The "Ignore case" option converts both inputs to lowercase before diffing, which is useful for case-insensitive comparisons like SQL keywords, environment variables, or natural language where capitalization changes are not significant.

The "Swap" button exchanges the contents of panels A and B, which is handy when you want to view the diff from the opposite perspective. The "Clear" button empties both panels so you can start fresh. The statistics bar at the top of the page gives you a quick count of additions, deletions, and unchanged lines so you can gauge the scope of changes at a glance.

Common use cases for diff comparison

Code review is the most common use case for a diff tool. When you're reviewing changes before a commit or pull request, pasting the before-and-after versions into the diff tool lets you see exactly what changed without needing to navigate a full Git interface. This is especially useful for small, isolated changes where you want a quick visual check.

Configuration file comparison is another frequent need. When debugging deployment issues, comparing production and staging config files can reveal subtle differences in environment variables, database connection strings, or feature flags that cause unexpected behavior. The ignore-whitespace option is particularly useful here since config files often get reformatted during copy-paste operations.

Content writers and editors use diff tools to track changes in documents. Comparing drafts shows exactly which sentences were added, removed, or reworded—similar to "Track Changes" in Word but for any plain text format. API response comparison is also common: comparing expected and actual JSON or XML responses during integration testing can pinpoint exactly which fields differ, making debugging faster than manual visual inspection.

Understanding diff output

The diff output uses a unified format similar to what you see in Git. Lines prefixed with a green "+" sign are additions—they exist in the modified version (B) but not in the original (A). Lines prefixed with a red "−" sign are deletions—they exist in the original but were removed or replaced in the modified version. Lines without a prefix are unchanged and appear in both versions at the same position.

The line number columns help you locate changes in the original files. The left column shows the line number from input A, and the right column shows the line number from input B. When a line is deleted, only the A column has a number. When a line is added, only the B column has a number. When a line is unchanged, both columns display their respective line numbers.

For large files, the statistics summary at the top provides a quick overview: how many lines were added, removed, and unchanged. This helps you assess the magnitude of changes before reading through the full diff. A diff with 3 additions and 2 deletions in a 500-line file is a quick review. A diff with 200 changes in a 500-line file warrants more careful inspection. These metrics help you allocate review time effectively.

Frequently Asked Questions

What is a diff tool?

A diff tool compares two pieces of text or code and highlights the differences between them. Lines that were added appear in green, lines that were removed appear in red, and unchanged lines appear normally. This is the same concept behind Git diffs, pull request reviews, and merge conflict resolution in software development.

How does the comparison algorithm work?

This tool uses a Longest Common Subsequence (LCS) algorithm, which is the same foundational approach used by Git and the classic Unix diff command. It finds the longest sequence of lines that appear in both inputs in the same order, then marks remaining lines as additions or deletions. This produces a minimal, readable diff output.

Can I compare code in any language?

Yes. The diff operates on plain text lines, so it works with any programming language, markup format, configuration file, or natural language text. It doesn't parse syntax—it compares lines as strings. This makes it universally compatible with JavaScript, Python, HTML, CSS, JSON, YAML, SQL, Markdown, and any other text format.

What does 'ignore whitespace' do?

When enabled, the tool trims leading and trailing whitespace from each line and collapses multiple spaces into one before comparing. This is useful when comparing code that has been reformatted or when indentation differences (tabs vs spaces, 2 vs 4 spaces) are not meaningful to your review.

What does 'ignore case' do?

When enabled, the tool converts both inputs to lowercase before comparing. This is useful for comparing text where capitalization differences don't matter, such as case-insensitive SQL keywords, configuration values, or natural language content where you want to focus on word changes rather than casing.

Is my data safe?

Yes. This tool runs entirely in your browser. Your text and code are never sent to a server. The diff computation happens locally using JavaScript, so you can safely compare sensitive code, configuration files, API responses, and private documents without any privacy concerns.

Privacy and methodology

This tool runs entirely in your browser. The diff algorithm uses a Longest Common Subsequence (LCS) approach with dynamic programming, similar to the classic Unix diff utility. No text or code is sent to any server. You can safely compare sensitive source code, configuration files, API responses, and private documents without privacy concerns.

Tool Vault — Text & Code Diff 2026. Fast, private, and mobile-friendly.