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
| Field | Type | Required | Description |
|---|---|---|---|
mode | "text" | "json" | required | Compare raw text line-by-line, or parse both sides as JSON first (semantic compare). |
a | string | required | Original (old) content. |
b | string | required | Changed (new) content. |
ignoreWhitespace | boolean | required | Ignore leading/trailing whitespace on each line when comparing (jsdiff ignoreWhitespace semantics). |
sortKeys | boolean | required | JSON mode only: recursively sort object keys before comparing, so pure key-order differences produce no diff. Arrays keep their order. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
rows | object[] | required | Per-line diff rows in display order. Empty when error is set. |
stats | object | required | Diff tallies. |
error | unknown | required | Error message when the diff could not be computed (JSON parse failure or inputs too different). |
errorSide | unknown | required | Which input failed JSON parsing, when applicable. |
errorLine | unknown | required | 1-based line of the JSON parse error, when applicable. |
errorColumn | unknown | required | 1-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.