POST/text

Compare Text

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

Parameters

emailquerystring

Your email address. Required if not using an API key.

output_typequerystringrequired

Specifies the type of output you receive in the response body. - `json`: Row metadata generated from diff computation (Content-Type: application/json) - `html`: Same HTML/CSS you see on the Diffchecker site (Content-Type: text/html) - `html_json`: Same HTML/CSS you see on the Diffchecker site, but split up and embedded in JSON (Content-Type: application/json)

Values: json, html, html_json

diff_levelquerystring

Specifies whether you want to diff by word or character. Default is `word`.

Values: word, character

Default: word

Request Bodyrequired

leftstringrequired

Left text you want to diff.

rightstringrequired

Right text you want to diff.

Responses

Diff computed successfully.

application/json

One of:

rowsobject[]
endboolean
startboolean
insideChangedboolean
leftobject
chunksobject[]
valuestring
typestring

Enum: equal, insert, remove

lineinteger
rightobject
chunksobject[]
valuestring
typestring

Enum: equal, insert, remove

lineinteger
addedinteger

Number of added chunks.

removedinteger

Number of removed chunks.

htmlstring

HTML markup of the diff table.

cssstring

CSS styles for the diff table.

Example: output_type=json
{
  "rows": [
    {
      "end": false,
      "left": {
        "chunks": [
          {
            "value": "roses are ",
            "type": "equal"
          },
          {
            "value": "red",
            "type": "remove"
          }
        ],
        "line": 1
      },
      "right": {
        "chunks": [
          {
            "value": "roses are ",
            "type": "equal"
          },
          {
            "value": "green",
            "type": "insert"
          }
        ],
        "line": 1
      },
      "insideChanged": true,
      "start": true
    },
    {
      "end": true,
      "left": {
        "chunks": [
          {
            "value": "",
            "type": "remove"
          },
          {
            "value": "violets are ",
            "type": "equal"
          },
          {
            "value": "blue",
            "type": "remove"
          }
        ],
        "line": 2
      },
      "right": {
        "chunks": [
          {
            "value": "",
            "type": "insert"
          },
          {
            "value": "violets are ",
            "type": "equal"
          },
          {
            "value": "purple",
            "type": "insert"
          }
        ],
        "line": 2
      },
      "insideChanged": true
    }
  ],
  "added": 3,
  "removed": 3
}
Example: output_type=html_json
{
  "html": "<table class=\"diff-table\">...</table>",
  "css": ".diff-table { font-family: monospace; ... }"
}

text/html

string

Example Request

curl
curl -X POST \
  "https://api.diffchecker.com/public/text?email=your%40email.com&output_type=json&diff_level=word" \
  -H "Content-Type: application/json" \
  -d '{
  "left": "roses are red\nviolets are blue",
  "right": "roses are green\nviolets are purple"
}'

Try It