---
title: "Diff two strings (line, word, or char)"
method: POST
path: "/text-diff.php"
tags: ["text"]
---

# Diff two strings (line, word, or char)

`POST /text-diff.php`

## Request

- Base URL: `https://mate.tools/api/v1`
- URL: `https://mate.tools/api/v1/text-diff.php`
- Auth: none declared

LCS-based diff. Returns structured changes (`+`/`-`/`=`), git-style unified diff, and a similarity score. Tokens are split by line by default; pass `mode=word` or `mode=char` for finer granularity.

## Request body

- object
  - `a` string, required
  - `b` string, required
  - `mode` 'line' | 'word' | 'char'
  - `context` integer

## Response `200`

Success

## Other responses

- `400`: Malformed request
- `413`: Request body or text exceeds 1 MB
- `429`: Rate limit exceeded (60/min, 600/hour per IP). Includes Retry-After header.

---

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