# Text Diff Maker

> Compare two short texts by complete line, inspect a deterministic minimum edit script and download a unified patch with accurate ranges, selected context and explicit missing-final-newline markers.

Use it: https://tessalor.com/en/text/text-diff-maker

This tool runs entirely in the browser. Nothing entered into it is uploaded.

## How it is done

1. Normalise CRLF and lone CR line endings to LF, while recording whether each document's final logical line has a terminating newline.
2. Build a longest-common-subsequence matrix over complete line text plus its termination state, choosing deletion before insertion when several minimum scripts tie.
3. Expand every changed edit by the requested number of unchanged context lines and merge ranges that touch or overlap into unified diff hunks.
4. Write cleaned --- and +++ labels, exact @@ start,count ranges and space, minus or plus line prefixes into a downloadable patch.

## Assumptions

- Comparison is line-based and exact after newline normalisation; whitespace, case and Unicode-normalisation differences are not ignored.
- Each side is limited to 2,000 characters, keeping the quadratic longest-common-subsequence matrix bounded in the browser.
- More than one minimum edit script can exist. Deletion-first ties make this output repeatable but not uniquely mathematically privileged.
- A syntactically formed patch can still fail against a third file whose surrounding content has changed; this tool does not apply or merge patches.

## Inputs

| Name | Label | Type | Default | Range |
| --- | --- | --- | --- | --- |
| `original` | Original text | textarea | alpha
beta
line 03
line 04
line 05
line 06
line 07
line 08
line 09
line 10
line 11
delta
 |  |
| `revised` | Revised text | textarea | alpha
beta revised
line 03
line 04
line 05
line 06
line 07
line 08
line 09
line 10
line 11
epsilon
 |  |
| `contextLines` | Context lines | integer | 3 | 0 to 10 |
| `fileLabel` | File label | text | document.txt |  |

## Outputs

- `changeSummary` — Change summary (text), primary
- `linesAdded` — Lines added (integer)
- `linesRemoved` — Lines removed (integer)
- `unchangedLines` — Lines unchanged (integer)
- `hunkCount` — Change hunks (integer)

## Questions

### Why is one changed line shown as one removal and one addition?

Unified diff has context, removed and added line records, not a separate replace record. A replacement therefore removes the old complete line and adds the new one.

### What do context lines change?

They change how much unchanged material surrounds an edit and whether nearby regions merge into one hunk. They do not change the underlying additions, removals or minimum edit script.

### Does a final newline difference count?

Yes. A text file ending in `same` is not byte-equivalent to one ending in `same` plus a newline, so the patch emits the conventional explicit marker for the incomplete line.

### Can the patch reveal a local directory path?

The label is reduced to its final path component and control characters are removed. The headers use only `a/label` and `b/label`, with no machine path or timestamp.

## Sources

- [Comparing and Merging Files — GNU Diffutils 3.12](https://www.gnu.org/software/diffutils/manual/diffutils.html) — Free Software Foundation, applies to Unified headers, hunks, ranges, context and incomplete lines. Retrieved 2026-08-01.
- [diff — compare two files](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/diff.html) — The Open Group, applies to Line comparison and portable diff terminology. Retrieved 2026-08-01.

## Variants

- [How do I make a unified diff patch from two texts?](https://tessalor.com/en/text/text-diff-maker/make-unified-diff-patch)
- [How do I compare two config files without context lines?](https://tessalor.com/en/text/text-diff-maker/compare-config-files-with-no-context)

---

Estimate, not advice. See https://tessalor.com/en/disclaimer.
Machine-readable catalogue: https://tessalor.com/api/tools.json
