Diff Checker API

Compare two texts or JSON documents online and see every change highlighted line by line. Whitespace-insensitive and key-sorted JSON modes. Free and instant.

The Diff Checker is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/diff-checker — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.

Request body

FieldTypeRequiredDescription
mode"text" | "json"requiredCompare raw text line-by-line, or parse both sides as JSON first (semantic compare).
astringrequiredOriginal (old) content.
bstringrequiredChanged (new) content.
ignoreWhitespacebooleanrequiredIgnore leading/trailing whitespace on each line when comparing (jsdiff ignoreWhitespace semantics).
sortKeysbooleanrequiredJSON mode only: recursively sort object keys before comparing, so pure key-order differences produce no diff. Arrays keep their order.

Response

FieldTypeRequiredDescription
rowsobject[]requiredPer-line diff rows in display order. Empty when error is set.
statsobjectrequiredDiff tallies.
errorunknownrequiredError message when the diff could not be computed (JSON parse failure or inputs too different).
errorSideunknownrequiredWhich input failed JSON parsing, when applicable.
errorLineunknownrequired1-based line of the JSON parse error, when applicable.
errorColumnunknownrequired1-based column of the JSON parse error, when applicable.

Example request

curl -X POST https://dot.tools/api/tools/diff-checker \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "json",
  "a": "{\n  \"name\": \"dot-api\",\n  \"version\": \"1.2.0\",\n  \"timeout\": 30,\n  \"retries\": 3\n}",
  "b": "{\n  \"name\": \"dot-api\",\n  \"version\": \"1.3.0\",\n  \"timeout\": 60,\n  \"retries\": 3\n}",
  "ignoreWhitespace": false,
  "sortKeys": true
}'

Sample response

{
  "ok": true,
  "result": {
    "rows": [
      {
        "type": "context",
        "text": "{",
        "oldLine": 1,
        "newLine": 1
      },
      {
        "type": "context",
        "text": "  \"name\": \"dot-api\",",
        "oldLine": 2,
        "newLine": 2
      },
      {
        "type": "context",
        "text": "  \"retries\": 3,",
        "oldLine": 3,
        "newLine": 3
      },
      {
        "type": "removed",
        "text": "  \"timeout\": 30,",
        "oldLine": 4,
        "newLine": null
      },
      {
        "type": "removed",
        "text": "  \"version\": \"1.2.0\"",
        "oldLine": 5,
        "newLine": null
      },
      {
        "type": "added",
        "text": "  \"timeout\": 60,",
        "oldLine": null,
        "newLine": 4
      },
      {
        "type": "added",
        "text": "  \"version\": \"1.3.0\"",
        "oldLine": null,
        "newLine": 5
      },
      {
        "type": "context",
        "text": "}",
        "oldLine": 6,
        "newLine": 6
      }
    ],
    "stats": {
      "added": 2,
      "removed": 2,
      "unchanged": 4
    },
    "error": null,
    "errorSide": null,
    "errorLine": null,
    "errorColumn": null
  }
}

Use the free Diff Checker in your browser, read the Diff Checker guide, or import the full OpenAPI specification.