---
title: "Use this when you need an exact line-level diff between two blocks of text instead of eyeballing the differences."
method: POST
path: "/v1/diff_text"
tags: ["text"]
---

# Use this when you need an exact line-level diff between two blocks of text instead of eyeballing the differences.

`POST /v1/diff_text`

## Request

- Base URL: `https://api.clean.tools`
- URL: `https://api.clean.tools/v1/diff_text`
- Auth: none declared

Use this when you need an exact line-level diff between two blocks of text instead of eyeballing the differences. Deterministic: same input, same output. Computes a longest-common-subsequence diff and returns every line tagged added, removed, or unchanged, plus per-category counts. Example: original "a\nb", modified "a\nB" -> added 1, removed 1, unchanged 1, with lines [{type:"unchanged",text:"a"},{type:"removed",text:"b"},{type:"added",text:"B"}]. Trailing edits produce separate removed+added lines rather than an in-place change. Inputs whose line-count product exceeds 4,000,000 are rejected as too large to diff.

## Request body

- object
  - `original` string, required: Original text.
  - `modified` string, required: Modified text.

## Response `200`

Structured tool result.

- object
  - `tool` string
  - `result` object
    - `added` integer, required: Number of lines present only in the modified text.
    - `removed` integer, required: Number of lines present only in the original text.
    - `unchanged` integer, required: Number of lines common to both texts.
    - `lines` object[], required: The full diff in order, one entry per line.
      - `type` 'added' | 'removed' | 'unchanged', required: How this line differs between the two texts.
      - `text` string, required: The line content (without its trailing newline).

## Other responses

- `400`: Invalid input or the tool reported an error.
- `413`: Request body exceeds the 128 KB limit.
- `429`: Rate limit exceeded; the response carries Retry-After and RateLimit-* headers — honor them and add jitter.

---

[API](https://skmtc.dev/clean/apis/clean-tools-api.md) · [All operations](https://skmtc.dev/clean/apis/clean-tools-api/llms.txt) · [OpenAPI document](https://skmtc.dev/clean/apis/clean-tools-api/revisions/a24a01d2833c?raw)
