Text Diff
Compare versions of code, contracts, and articles and visualize every change with color coding.
What it's for
Visible differences in seconds
Line and character diff
Visualize changes at the line level and at the character level within each modified line.
100% private
Comparison happens in your browser. Your texts are never sent to any server.
Myers algorithm
Implementation of the Myers diff O(n+d) algorithm, the same one git uses internally for its diffs.
Instant
Results appear as you paste the text, no need to click convert.
How it works
Three steps, no hassle
Paste the two texts
Enter the original text in the left panel and the modified text in the right panel. They can be code, documents, or any plain text.
Visualize the differences
Added lines appear in green, deleted lines in red, and modified lines show the exact change highlighted at the character level.
Analyze the changes
Navigate between differences with previous/next buttons. See a summary of added, deleted, and unchanged lines.
FAQ
Got questions?
Modern diff algorithms are based on computing the LCS (Longest Common Subsequence). Given two texts A and B, the algorithm finds the longest sequence of lines that appears in both in the same order. Lines from A that are not part of the LCS are marked as deleted (red), and lines from B that are not part of it are marked as added (green). The Hunt-McIlroy algorithm (1975), used in the original Unix diff command, formalized this approach.
Green indicates lines added in the new text that did not exist in the original. Red indicates deleted lines that were in the original and are no longer present. Yellow or no color indicates unchanged lines (context). In character-level diff mode, within a modified line, new characters are highlighted in dark green and deleted characters in dark red, allowing you to see the exact change within the line.
Line-by-line diff treats each line as an atomic unit: a line is either present or not, just like git diff does. It is ideal for code where changes are between complete lines. Character-by-character diff (also called word diff or char diff) operates within each modified line and shows exactly which characters or words changed. It is more useful for prose, contracts, or text where changes are minor edits within paragraphs.
Diff is fundamental in version control (git diff shows changes before a commit), code review (pull requests on GitHub show a diff), comparison of legal documents (contracts, terms of service between versions), journalism and fact-checking (comparing versions of press releases), and debugging (comparing expected output with actual output in tests). It is also used in software patches: .patch files are unified diffs that git apply can apply to a repository.
LCS (Longest Common Subsequence) is the problem of finding the longest subsequence that two sequences have in common without reordering elements. For text diff, the sequences are the lines of the text. The LCS represents the lines that did not change; everything not in the LCS is a change. The standard dynamic programming algorithm for LCS has O(n×m) complexity where n and m are the lengths of the two sequences, though more efficient algorithms like Myers diff (1986) achieve O(n+d) where d is the number of differences.
How text diff works: from the Unix command to git
The diff command was introduced in Unix by Doug McIlroy in 1974 and became a fundamental tool in the Unix ecosystem. Its original algorithm, formalized by Hunt and McIlroy in the paper 'An Algorithm for Differential File Comparison' (1975), computes the longest common subsequence (LCS) between two files and expresses the differences as a minimal set of insertion and deletion operations. This mathematical principle remains the foundation of all modern diff tools.
In 1986, Eugene Myers published an improved algorithm that reduces complexity to O(n+d) where d is the number of differences, making it significantly faster when files are similar (few differences). This is the algorithm Git uses internally for git diff, git log -p, and pull request views on GitHub and GitLab. The unified diff output format (with lines prefixed by +, -, and space) has become the universal standard for exchanging patches between software projects.
Beyond code, diff has applications in data journalism (comparing versions of official documents), law (detecting changes between contract versions), and science (comparing genomic sequences). Convertir.ai implements the Myers diff algorithm entirely in the browser, with both line-level and character-level visualization, without sending texts to any server. This is especially relevant for comparing confidential documents such as contracts, proprietary code, or sensitive data.