Diff Checker
Compare two texts line by line and see exactly what changed.
| - | function greet(name) { |
| - | console.log("Hello, " + name); |
| - | return name; |
| + | function greet(name, greeting = "Hello") { |
| + | console.log(greeting + ", " + name + "!"); |
| } | |
| const user = "Alice"; | |
| + | const admin = "Bob"; |
| greet(user); | |
| + | greet(admin, "Hi"); |
Text diff — what changed?
Knowing exactly what changed between two versions of a document or code file is one of the most common tasks in software development and content work. A diff tool shows you the minimal set of changes needed to go from the original to the modified version.
Common uses
- Code review — check what changed in a file before committing
- Config files — spot differences between production and staging configs
- Legal/contracts — compare two versions of an agreement
- Content editing — track what an editor changed in your draft
- Debugging — compare a working vs broken version of a config or snippet
How LCS diff works
The Longest Common Subsequence algorithm finds the largest set of lines that appear in both texts in the same order (but not necessarily contiguous). Lines in this common set are "unchanged". Everything else is either added (exists only in modified) or removed (exists only in original). This is the same fundamental algorithm used by git, diff, and most version control systems.
Frequently asked questions
- How does the diff checker work?
- The tool uses the Longest Common Subsequence (LCS) algorithm to find lines that appear in both texts. Lines only in the original are shown in red (removed), lines only in the modified are shown in green (added), and common lines are shown without highlighting.
- What can I use this for?
- Comparing versions of code, configuration files, documents, or any text. It's useful for reviewing changes before committing to version control, comparing contract revisions, checking what changed between two versions of a file, or spotting differences in two similar text blocks.
- Is there a character or line limit?
- The LCS algorithm is limited to 300 lines per side for performance. For texts longer than this, a simplified fallback is used showing all original lines as removed and all modified lines as added. For large file diffs, use a dedicated version control tool like git diff.
- Does the diff work on word level or line level?
- This tool performs line-by-line comparison. Each entire line is compared as a unit. This is the standard approach for code and document diffs — the same method used by git diff by default.
- Is my text sent to a server?
- No. All comparison happens entirely in your browser. No data is transmitted or stored.
Related tools
- JSON Formatter
Format, beautify, minify, and validate JSON in your browser
- QR Code Generator
Generate QR codes for URLs, text, Wi-Fi, and more. Download as PNG.
- Password Generator
Generate strong, random passwords with custom length and character sets.
- Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to plain text.
- URL Encoder / Decoder
Encode or decode URLs and query strings with percent-encoding.