{"title":"Find the Actual Change Between Two API Responses","excerpt":"Two API responses look almost identical, but amount changed from a number to a string. Use JSON Diff to find that path, read array changes correctly, and decide which differences need a contract test.","canonicalUrl":"https://automationtester.in/blog/tools-reviews/compare-api-responses-json-diff","category":{"name":"Tools & Reviews","slug":"tools-reviews"},"tags":["json-diff","api-testing","contract-testing","json"],"author":{"name":"Shashank Rawlani","url":"https://shashank.rawlani.com","linkedin":"https://www.linkedin.com/in/shashankrawlani/"},"datePublished":"2026-09-27T05:30:00.000Z","dateModified":"2026-10-14T10:26:49.397Z","coverImage":{"url":"https://ik.imagekit.io/automationtester/automationtester-in/blog/covers/v3/compare-api-responses-json-diff.webp","alt":"Two dark JSON response panels share four rows. The left panel marks an amount row orange, the right panel marks its changed value green and adds a separate green payment row. A central comparison node joins the panels."},"contentHtml":"<p>Paste the old and new JSON responses into <a href=\"https://automationtester.in/tools/json-diff\">JSON Diff</a>. The result names changed values by path and separates additions, removals, and type changes. Use that list to decide which differences deserve an assertion or a contract review.</p>\n\n<p>An API test says only that the response changed. Scanning two formatted payloads can miss a number that became a string, especially when most fields stayed the same. A plain text diff also spends space on indentation and property order. Start with the values.</p>\n\n<h2 id=\"two-payment-responses\">A payment response with three changes</h2>\n\n<p>Open the tool. Replace the left pane with the earlier response and the right pane with the new one. The comparison updates as you edit; there is no run button.</p>\n\n<pre class=\"language-json\"><code class=\"language-json\">{\"id\":\"A-17\",\"status\":\"pending\",\"amount\":499,\n \"items\":[{\"sku\":\"P1\",\"qty\":1}]}</code></pre>\n\n<pre class=\"language-json\"><code class=\"language-json\">{\"id\":\"A-17\",\"status\":\"paid\",\"amount\":\"499\",\n \"items\":[{\"sku\":\"P1\",\"qty\":1}],\"paymentId\":\"p_8\"}</code></pre>\n<a href=\"https://automationtester.in/tools/json-diff#p=eyJ2IjoxLCJsZWZ0Ijoie1wiaWRcIjpcIkEtMTdcIixcInN0YXR1c1wiOlwicGVuZGluZ1wiLFwiYW1vdW50XCI6NDk5LFxuIFwiaXRlbXNcIjpbe1wic2t1XCI6XCJQMVwiLFwicXR5XCI6MX1dfSIsInJpZ2h0Ijoie1wiaWRcIjpcIkEtMTdcIixcInN0YXR1c1wiOlwicGFpZFwiLFwiYW1vdW50XCI6XCI0OTlcIixcbiBcIml0ZW1zXCI6W3tcInNrdVwiOlwiUDFcIixcInF0eVwiOjF9XSxcInBheW1lbnRJZFwiOlwicF84XCJ9In0\">Try this in JSON Diff</a>\n\n<p>The result has <code>1 added</code>, <code>0 removed</code>, <code>2 changed</code>, and <code>3 unchanged</code> leaf values. It lists <code>status</code> as changed, <code>amount</code> as a <em>type change</em>, and <code>paymentId</code> as added. The <code>id</code> and the two fields inside <code>items[0]</code> did not change. That is more useful than a red/green block around the whole response: <code>amount</code> now needs a contract decision, while <code>paymentId</code> may be an intentional addition.</p>\n\n<h2 id=\"what-comparison-means\">Read the paths before fixing tests</h2>\n\n<p>The tool parses both panes as JSON and walks matching object keys and array positions. <code>items[0].qty</code> is the quantity in the first array element. If an item moves from index 0 to index 1, the tool compares those positions and may report several changes even when the item itself is unchanged. It does not match records by <code>sku</code> or another identity field.</p>\n\n<p>That matters for API assertions. If item order is part of the contract, positional differences are evidence. If order is irrelevant, compare items by a stable key in the test instead. <a href=\"https://automationtester.in/tools/json-formatter\">JSON Formatter</a> helps when either side is invalid; this diff tool reports which pane failed to parse, but it cannot infer a missing comma's intended value.</p>\n\n<h2 id=\"contract-versus-difference\">A difference is not a verdict</h2>\n\n<p>The tool reports structure and values, not whether a release is compatible. RFC 8259 defines an object as an unordered collection and an array as ordered; the tool's positional array comparison follows that distinction. A new optional property may be harmless for one consumer and break another that rejects unknown fields. Check the actual consumer contract before labeling a change safe.</p>\n\n<p>For a repeated check in CI, write an assertion or validate against the agreed schema. A browser comparison is useful during investigation, but it is not a stored regression test.</p>\n\n<h2 id=\"diff-questions\">Two questions to settle</h2>\n\n<p><strong>Does key order matter here?</strong> JSON object member order carries no meaning in RFC 8259, and the tool compares keys rather than text positions. Array order does affect its result.</p>\n\n<p><strong>Can I paste a broken response?</strong> You can, but the tool stops at the JSON parse error and identifies the invalid pane. Repair or isolate that input before interpreting differences.</p>\n\n<h2 id=\"diff-apply\">Carry the changed paths into a test</h2>\n\n<p>Compare one response from before and after a real change. Save the changed paths, the two values, and the consumer decision. Turn each consequential difference into a test that checks the intended contract.</p>\n\n<h2 id=\"diff-references\">JSON semantics and tool reference</h2>\n<ul>\n<li><a href=\"https://www.rfc-editor.org/info/rfc8259/\">RFC 8259, JSON Data Interchange Format</a>: object and array semantics, plus the JSON grammar.</li>\n<li><a href=\"https://automationtester.in/tools/json-diff\">AutomationTester.in JSON Diff</a>: the comparison interface and its displayed result.</li>\n</ul>\n"}