# Text diff

Compare two texts line by line and get a unified diff with counts of added and removed lines.

- Endpoint: `POST https://setget.net/v1/tools/diff` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `diff`
- Page: https://setget.net/tools/diff

## Inputs

- `before` (required, string): The original text.
- `after` (required, string): The changed text.
- `context` (optional, integer, default `3`, range 0..1000): Unchanged lines to show around each change.

## Example 1

```json
{"input":{"before":"apple\nbanana\ncherry\n","after":"apple\nblueberry\ncherry\ndate\n"}}
```

Result:

```json
{"text":"--- before\n+++ after\n@@ -1,3 +1,4 @@\n apple\n-banana\n+blueberry\n cherry\n+date\n","added":2,"removed":1,"hunks":1,"equal":false}
```

## Example 2: Identical texts

```json
{"input":{"before":"same\n","after":"same\n"}}
```

Result:

```json
{"text":"","added":0,"removed":0,"hunks":0,"equal":true}
```

**What does "\ No newline at end of file" mean?** The line above it is the last line of a text that does not end with a line break. The marker lets a patch tool rebuild the text exactly.

**Can I apply the result with patch or git apply?** Yes. The output is a standard unified diff. The file names are "before" and "after".

**Are Windows line endings a difference?** No. Windows (CRLF) line endings are treated as plain line breaks in both texts.
