/document/richtextCompare Documents (Rich Text)
Compute a rich-text diff between two PDFs with polygon geometry and optional visual object comparisons. Supports multipart/form-data uploads and JSON with base64-encoded data URLs.
Parameters
Diffchecker-VersionheaderstringAPI version to serve the request with. Defaults to the newest version, currently 1, when omitted. An unsupported version is rejected with 400 UNSUPPORTED_API_VERSION. See Versioning and Deprecation in the getting started guide.
Values: 1
Default: 1
emailquerystringYour email address. Required if not using an API key.
output_typequerystringrequiredSpecifies the response format.
- json: Structured rich-text payload with polygons + page metadata (Content-Type: application/json)
- html: Self-contained HTML (Content-Type: text/html)
- html_json: HTML/CSS parts in JSON (Content-Type: application/json)
- pdf: Binary PDF export with rich-text highlights (Content-Type: application/pdf)
Values: json, html, html_json, pdf
input_typequerystringSpecifies the request content-type.
- form: multipart/form-data (default)
- json: application/json
Values: json, form
Default: form
diff_levelquerystringSpecifies whether to diff by word or character. Default is word.
Values: word, character
Default: word
page_image_scalequerynumberRendering scale used for page image generation and geometry alignment. Allowed range is 0.25 to 4. For non-pdf outputs, explicit values above a document-safe runtime maximum return 400.
Default: 1
show_movesquerystringInclude move detection in the diff. Default is true.
Values: true, false
Default: true
compare_font_familyquerystringCompare font family style changes. Default is false.
Values: true, false
Default: false
compare_font_sizequerystringCompare font size style changes. Default is false.
Values: true, false
Default: false
compare_font_colorquerystringCompare text color style changes. Default is false.
Values: true, false
Default: false
compare_regular_imagesquerystringCompare raster image changes. Images are compared by their own pixels where possible, so content drawn over an image isn't reported as an image change. Default is false.
Values: true, false
Default: false
compare_vector_graphicsquerystringCompare vector graphic changes. Default is false.
Values: true, false
Default: false
compare_form_xobjectsquerystringCompare form XObject changes. Default is false.
Values: true, false
Default: false
compare_shading_objectsquerystringCompare shading object changes. Default is false.
Values: true, false
Default: false
pdf_layoutquerystringLayout used when output_type=pdf.
- split-view (default)
- alternating
- left-document
- right-document
Values: split-view, alternating, left-document, right-document
Default: split-view
Request Bodyrequired
left_pdfstring (binary)requiredLeft PDF file you want to diff. File extension must be .pdf.
right_pdfstring (binary)requiredRight PDF file you want to diff. File extension must be .pdf.
Responses
Every response includes the X-Credits-Used header. In JSON responses, the same value is also available in the creditsUsed field.
Rich-text diff computed successfully.
application/json
One of:
creditsUsedintegerrequiredCredits charged for the diff request.
diffobjectrequiredleftobject[]requiredidintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[][]requiredmoveSegmentsobjecttypestringEnum: remove, insert
polygonsobject[]fontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringContent hash of the imageUrl pixels, prefixed with the object type. Equal hashes mean identical images.
objectTypestringEnum: image, vector, form, shading
imageUrlstringBase64-encoded PNG data URL. For image objects this is usually the image's own pixels from the PDF, at page_image_scale pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within bounds, as for other object types.
widthnumberPixel width of imageUrl.
heightnumberPixel height of imageUrl.
byteSizenumberboundsobjectPage-space box of the object. For image objects, the part its clip leaves visible.
leftnumbertopnumberrightnumberbottomnumberrightobject[]requiredidintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[][]requiredmoveSegmentsobjecttypestringEnum: remove, insert
polygonsobject[]fontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringContent hash of the imageUrl pixels, prefixed with the object type. Equal hashes mean identical images.
objectTypestringEnum: image, vector, form, shading
imageUrlstringBase64-encoded PNG data URL. For image objects this is usually the image's own pixels from the PDF, at page_image_scale pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within bounds, as for other object types.
widthnumberPixel width of imageUrl.
heightnumberPixel height of imageUrl.
byteSizenumberboundsobjectPage-space box of the object. For image objects, the part its clip leaves visible.
leftnumbertopnumberrightnumberbottomnumberchangeLog(one of)[]requiredOne of:
chunkIdintegercontentBeforestringFor a replace, the text, or for visual content a PNG data URL, before the change. When only one side of a visual replacement has the image's own pixels, contentBefore and contentAfter are both the rendered page within bounds, which is how the two were compared.
contentAfterstringFor a replace, the text or PNG data URL after the change. See contentBefore.
contentTypestringEnum: text, visual
typestringEnum: insert, remove, replace, move, style
pageIndexintegerchunkIdintegertextstringtypestringEnum: style
chunkBeforeobjectRepresents a single diff chunk. Text chunks include text.
Visual chunks can include image metadata. Equal text chunks can expose style flags.
idintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[]requiredmoveSegmentsobjectfontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringContent hash of the imageUrl pixels, prefixed with the object type. Equal hashes mean identical images.
objectTypestringEnum: image, vector, form, shading
imageUrlstringBase64-encoded PNG data URL. For image objects this is usually the image's own pixels from the PDF, at page_image_scale pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within bounds, as for other object types.
widthnumberPixel width of imageUrl.
heightnumberPixel height of imageUrl.
byteSizenumberboundsobjectPage-space box of the object. For image objects, the part its clip leaves visible.
leftnumbertopnumberrightnumberbottomnumberchunkAfterobjectRepresents a single diff chunk. Text chunks include text.
Visual chunks can include image metadata. Equal text chunks can expose style flags.
idintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[]requiredmoveSegmentsobjectfontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringContent hash of the imageUrl pixels, prefixed with the object type. Equal hashes mean identical images.
objectTypestringEnum: image, vector, form, shading
imageUrlstringBase64-encoded PNG data URL. For image objects this is usually the image's own pixels from the PDF, at page_image_scale pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within bounds, as for other object types.
widthnumberPixel width of imageUrl.
heightnumberPixel height of imageUrl.
byteSizenumberboundsobjectPage-space box of the object. For image objects, the part its clip leaves visible.
leftnumbertopnumberrightnumberbottomnumberleftobjectrequiredpageCountintegerrequiredpageDimensionsobject[]requiredwidthnumberrequiredheightnumberrequiredrotationsinteger[]requiredPer-page /Rotate as PDFium quarter turns. 0=0°, 1=90°, 2=180°, 3=270°.
pageImagesstring[]pageImageScalenumberrequiredrightobjectrequiredpageCountintegerrequiredpageDimensionsobject[]requiredwidthnumberrequiredheightnumberrequiredrotationsinteger[]requiredPer-page /Rotate as PDFium quarter turns. 0=0°, 1=90°, 2=180°, 3=270°.
pageImagesstring[]pageImageScalenumberrequiredcreditsUsedintegerrequiredCredits charged for the diff request.
htmlstringrequiredHTML markup of the diff table.
cssstringrequiredCSS styles for the diff table.
Example: output_type=json
{
"creditsUsed": 1,
"diff": {
"left": [
{
"id": 0,
"type": "remove",
"pageIndex": 0,
"text": [
"Left"
],
"polygons": [
[
[
72,
720.64
],
[
72,
706.03
],
[
90.33,
706.03
],
[
90.33,
720.64
]
]
]
}
],
"right": [
{
"id": 0,
"type": "insert",
"pageIndex": 0,
"text": [
"Right"
],
"polygons": [
[
[
72,
720.64
],
[
72,
706.03
],
[
97.65,
706.03
],
[
97.65,
720.64
]
]
]
}
],
"changeLog": [
{
"chunkId": 0,
"contentBefore": "Left",
"contentAfter": "Right",
"contentType": "text",
"type": "replace",
"pageIndex": 0
}
]
},
"left": {
"pageCount": 1,
"pageDimensions": [
{
"width": 612,
"height": 792
}
],
"rotations": [
0
],
"pageImages": [
"data:image/png;base64,..."
],
"pageImageScale": 1
},
"right": {
"pageCount": 1,
"pageDimensions": [
{
"width": 612,
"height": 792
}
],
"rotations": [
0
],
"pageImages": [
"data:image/png;base64,..."
],
"pageImageScale": 1
}
}Example: output_type=html_json
{
"creditsUsed": 1,
"html": "<div class=\"rich-text-layout\">...</div>",
"css": "body { ... }"
}text/html
stringapplication/pdf
string (binary)Example Request
curl -X POST \
"https://api.staging.diffchecker.com/public/document/richtext?email=your@email.com&output_type=json&input_type=json&diff_level=word&page_image_scale=1&show_moves=true&compare_font_family=false&compare_font_size=false&compare_font_color=false&compare_regular_images=false&compare_vector_graphics=false&compare_form_xobjects=false&compare_shading_objects=false&pdf_layout=split-view" \
-H "Content-Type: application/json" \
-d '{
"left_pdf": "data:application/pdf;base64,...",
"right_pdf": "data:application/pdf;base64,..."
}'Try It
Click or drag to upload
Click or drag to upload
Understanding the JSON Output
When output_type=json, the response includes polygon overlays and page metadata for both documents. This output is useful for custom viewers, rendering overlays, and downstream automation.
diff.left and diff.right
{
"diff": {
"left": [
{
"id": 0,
"type": "remove",
"pageIndex": 0,
"text": [
"Left"
],
"polygons": [
[
[
72,
720.64
],
[
72,
706.03
],
[
90.33,
706.03
],
[
90.33,
720.64
]
]
]
}
],
"right": [
{
"id": 0,
"type": "insert",
"pageIndex": 0,
"text": [
"Right"
],
"polygons": [
[
[
72,
720.64
],
[
72,
706.03
],
[
97.65,
706.03
],
[
97.65,
720.64
]
]
]
}
]
}
}The left and right arrays contain chunk-level changes for each document side.
typeDiff classification for the chunk (insert, remove, move, or equal).pageIndexZero-based page index where this chunk appears.polygonsPolygon coordinates in PDF space that bound the changed region.textText lines for text chunks. Visual chunks use visual object metadata instead.diff.changeLog
{
"changeLog": [
{
"chunkId": 0,
"chunkIdAfter": 0,
"contentBefore": "Left",
"contentAfter": "Right",
"contentType": "text",
"type": "replace",
"pageIndex": 0,
"pageIndexAfter": 0
}
]
}changeLog is a linear summary of detected changes.
typeChange kind such as replace, insert, remove, move, or style.contentTypeIndicates whether a change is text or visual content.contentBefore / contentAfterHuman-readable before and after values when available.left and right metadata
{
"left": {
"pageCount": 1,
"pageDimensions": [
{
"width": 612,
"height": 792
}
],
"rotations": [
0
],
"pageImages": [
"data:image/png;base64,..."
],
"pageImageScale": 1
},
"right": {
"pageCount": 1,
"pageDimensions": [
{
"width": 612,
"height": 792
}
],
"rotations": [
0
],
"pageImages": [
"data:image/png;base64,..."
],
"pageImageScale": 1
}
}Both sides include page-level rendering metadata used to align overlays and exported views.
pageDimensionsWidth and height for each page, already scaled for rendering.rotationsPage rotation values used for coordinate mapping.pageImagesData URLs for rendered page backgrounds (omitted for PDF export output).pageImageScaleEffective render scale used after runtime safety checks.