# Text & code diff checker

> Compare two snippets line by line. See added and removed lines, check final newlines and optionally ignore trailing spaces. No code is executed.

- Canonical HTML: [https://unrust.dev/tools/text-diff](https://unrust.dev/tools/text-diff)
- Markdown representation: [https://unrust.dev/tools/text-diff/index.md](https://unrust.dev/tools/text-diff/index.md)

## How to use the tool

Paste before and after text, then inspect the line comparison. Each side accepts up to 400 lines and 40,000 characters. CRLF and CR become LF for comparison. Trailing-space ignoring is optional; final-newline differences remain visible. The downloadable report is readable text, not an apply-ready patch.

## Worked example

The example reports one removed line and one added line. Changing || to ?? preserves an explicit zero; the diff shows the edit, but a reviewer still needs to decide whether that behavior matches the contract.

```text
- return value || 3;
+ return value ?? 3;
```

Inputs stay in your browser. These are open learning examples, not scored diagnostic drills.

[Read a code diff for behavior, not just changed lines](https://unrust.dev/blog/review-a-code-diff-with-intent/index.md)

[Git: diff and whitespace comparison options](https://git-scm.com/docs/git-diff)

## Practice explaining a behavior change

A diff changes value || 3 to value ?? 3. What happens when value is 0, and what decides whether the change is correct?

The old expression returns 3; the new one returns 0. Whether that is correct depends on whether zero is valid in the contract. A smaller diff does not mean a smaller behavior change. Check null, undefined and other relevant inputs too.

Original open example, not a scored drill. Close tools before an unassisted session.

[Prepare for a code review](https://unrust.dev/use-cases/prepare-for-code-review/index.md)

[Take the free diagnostic](https://unrust.dev/diagnostic/index.md)
