For AI agents: the complete documentation index is available at /en/llms.txt, the full documentation bundle is available at /en/llms-full.txt, and this page is available as Markdown at /en/guide/text/text-diff.md.
  • English
  • Text Diff

    Text Diff is an offline two-pane text and file comparison tool. Beyond highlighting changes, it states in one sentence which line and which field the first difference starts at — so you don't have to hunt for the starting point in a screen full of red and green.

    Text Diff interface

    30-second quickstart
    1. Paste text into each pane, or drag files into A and B
    2. The dropdown above the result shows the detected format ("Detected as: CSV"); switch it if wrong
    3. The banner spells out where the first difference is — click "Jump" to go there
    4. Need to hand it to someone? "Export diff" gives you a git apply-ready .patch

    Two-pane input and folding

    The input area is a pair of A / B editors with a swap button in the middle:

    • Each pane header shows the filename ("Manual input" when typed) and line count; once a file is loaded it also offers an encoding dropdown, copy, and clear
    • When both sides have content and a diff exists, the result area offers Hide inputs — collapse the editors into a one-line summary (A/B filenames, line counts, swap button) and give the screen to the diff
    • Click Edit inputs anytime to go back; the summary bar can also swap A/B or clear both sides

    First-difference locator

    This is what sets the tool apart from a plain diff: the banner describes the first difference in natural language, phrased per format:

    FormatExample message
    CSV / TSVLine 12, column 3 "price" differs
    INILine 8, value of key "timeout" differs
    Plain textLine 5, char 17 differs
    Added/removed lineLine 20: a line was added in B

    Pair it with the Previous / Next buttons to step through blocks; the header also shows "block i of n".

    Format detection

    The dropdown above the result reads "Detected as: …". Detection combines file extension and content, and can always be overridden:

    • Plain text: line-by-line comparison
    • CSV / TSV: guesses the delimiter first (whichever of , \t ; | yields the most consistent column count), then compares by column, handling quoted fields and "" escapes
    • INI: compares key/value pairs and names the key whose value changed
    • JSON: currently compared as text lines (a notice is shown)

    Comparison options

    • Diff only (on by default): fold away identical content, keeping just the diff blocks
    • Context lines: how many lines to keep around each difference — "Changed lines only" or ±1 / ±3 / ±5 / ±10 lines (default ±1)
    • Character-level (on by default): within a modified row, mark exactly which characters changed
    • Ignore surrounding whitespace: skip differences caused by edge spacing
    • Ignore case: skip letter-case differences
    • Clear both sides: wipe both inputs in one click

    Views and navigation

    • Side by side / Inline: switch between the two-pane and unified views at any time
    • Maximize / Exit maximize: full-screen mode for long files; press Esc to exit
    • Swap A/B: exchange the two sides in one click
    • Expand folds: identical runs collapse to "⋯ N identical lines hidden (click to expand)"
    • Stats: similarity percentage, line counts for A and B, and ~changed / +added / −deleted counters (hover for the full "N differences · X changed / Y added / Z deleted" detail)
    • Hide inputs: collapse the editors into a summary bar, as described above

    Performance guard

    When the two sides diverge heavily, a line-level diff can take a long time. A 3-second timeout stops the run and shows "comparison timed out" rather than hanging the page. Click "Compare anyway" to force a full run with no time limit for that comparison. Any content change re-arms the guard.

    For longer inputs (roughly 10,000 characters combined), the comparison is handed to a Web Worker on a background thread, so typing and scrolling stay smooth; if the browser lacks Web Workers or the worker fails, it falls back to the main thread (deferred by a frame so click feedback paints first).

    Encoding detection

    Uploaded files are auto-detected as UTF-8, GBK, Big5, UTF-16LE, and other common encodings. The encoding dropdown in each pane header lets you re-decode manually when detection is off — especially useful for CSVs exported from different systems, GBK config files in legacy projects, and Windows logs.

    Export

    • Copy A / Copy B: copy either side out
    • Export diff: generate a standard unified diff (.patch) for git apply or a code review tool. The filename defaults to B's filename

    Common patterns

    • Verify a config change: drop in two .ini / .env files and read off which key's value moved
    • Compare tabular data: two exported CSVs, located down to the exact field
    • Self-review before a PR: compare local changes against the deployed version and export a .patch
    • Proofread a translation: enable "Ignore surrounding whitespace" to see only substantive edits between revisions

    Everything runs locally in your browser — nothing is uploaded — safe for sensitive configs and private code.