/textCompare Text
Compute a diff between two text strings with configurable output formats.
Parameters
emailquerystringYour email address. Required if not using an API key.
output_typequerystringrequiredSpecifies 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_levelquerystringSpecifies whether you want to diff by word or character. Default is `word`.
Values: word, character
Default: word
Request Bodyrequired
leftstringrequiredLeft text you want to diff.
rightstringrequiredRight text you want to diff.
Responses
Diff computed successfully.
application/json
One of:
rowsobject[]endbooleanstartbooleaninsideChangedbooleanleftobjectchunksobject[]valuestringtypestringEnum: equal, insert, remove
lineintegerrightobjectchunksobject[]valuestringtypestringEnum: equal, insert, remove
lineintegeraddedintegerNumber of added chunks.
removedintegerNumber of removed chunks.
htmlstringHTML markup of the diff table.
cssstringCSS 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
stringExample Request
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"
}'