---
title: "Compare Text"
method: POST
path: "/text"
---

# Compare Text

`POST /text`

## Request

- Base URL: `https://api.diffchecker.com/public`
- URL: `https://api.diffchecker.com/public/text`
- Auth: one of:
  - API key in header `X-Api-Key`
  - API key in query parameter `email`

Compute a diff between two text strings with configurable output formats.

## Query parameters

- `email` string, email
- `output_type` 'json' | 'html' | 'html_json', required
- `diff_level` 'word' | 'character'

## Headers

- `Diffchecker-Version` '1'

## Request body

- object
  - `left` string, required: Left text you want to diff.
  - `right` string, required: Right text you want to diff.

## Response `200`

Diff computed successfully.

- union
  - TextDiffJsonResponse
    - `creditsUsed` integer, required: Credits charged for the diff request.
    - `rows` object[], required
      - `end` boolean
      - `start` boolean
      - `insideChanged` boolean
      - `left` DiffSide
        - `chunks` object[]
          - `value` string
          - `type` 'equal' | 'insert' | 'remove'
        - `line` integer
      - `right` DiffSide
        - `chunks` object[]
          - `value` string
          - `type` 'equal' | 'insert' | 'remove'
        - `line` integer
    - `added` integer, required: Number of added chunks.
    - `removed` integer, required: Number of removed chunks.
  - HtmlJsonResponse
    - `creditsUsed` integer, required: Credits charged for the diff request.
    - `html` string, required: HTML markup of the diff table.
    - `css` string, required: CSS styles for the diff table.

## Other responses

- `400`: One or more validation errors occurred, or the JSON body could not be parsed.
- `401`: Authentication failed. Provide a valid email or API key. Depending on the failure, the response can include more specific error codes.
- `404`: No endpoint matches the request path.
- `405`: The endpoint exists but does not support the request method. The `Allow` response header lists the methods it does support.
- `413`: The request exceeded the active size limit for the caller's authentication method or plan.
- `415`: The request Content-Type is not one this endpoint accepts. `/text` accepts only application/json; the upload endpoints accept application/json and multipart/form-data.
- `429`: Rate limit exceeded. Depending on the throttle, the response may also include `retryAfterSeconds` and a `Retry-After` response header.
- `500`: The server hit an unexpected failure while handling the request. A failure after the diff was recorded can still incur charges. Check creditsUsed and X-Credits-Used to determine whether credits were charged before retrying.

---

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