[{"data":1,"prerenderedAt":593},["ShallowReactive",2],{"guide-comparing-api-responses":3},{"id":4,"title":5,"body":6,"date":584,"description":585,"extension":586,"meta":587,"navigation":588,"path":589,"readingTime":434,"seo":590,"stem":591,"__hash__":592},"guides\u002Fguides\u002Fcomparing-api-responses.md","Comparing API Responses: Find Differences Fast",{"type":7,"value":8,"toc":563},"minimark",[9,14,18,21,50,54,59,62,149,152,156,203,207,211,214,224,228,231,302,310,314,332,340,344,348,351,357,438,442,445,450,454,457,462,466,498,502,522,526,547,551,559],[10,11,13],"h2",{"id":12},"why-compare-api-responses","Why Compare API Responses?",[15,16,17],"p",{},"When you consume or build APIs, the structure and content of responses matter. A changed field name, a missing property, or a shifted data type can break downstream code silently. Comparing responses across environments, versions, or deployments helps you catch these issues before users do.",[15,19,20],{},"Common scenarios where response comparison saves time:",[22,23,24,32,38,44],"ul",{},[25,26,27,31],"li",{},[28,29,30],"strong",{},"Regression testing"," — Compare staging and production responses after a deploy",[25,33,34,37],{},[28,35,36],{},"Integration validation"," — Verify that a third-party API still returns the expected shape",[25,39,40,43],{},[28,41,42],{},"Version migration"," — Check what changed between API v1 and v2",[25,45,46,49],{},[28,47,48],{},"Debugging"," — Spot why the same request returns different results on two servers",[10,51,53],{"id":52},"what-to-compare-in-an-api-response","What to Compare in an API Response",[55,56,58],"h3",{"id":57},"structure-vs-content","Structure vs. Content",[15,60,61],{},"Two kinds of differences matter in API responses:",[63,64,65,81],"table",{},[66,67,68],"thead",{},[69,70,71,75,78],"tr",{},[72,73,74],"th",{},"Type",[72,76,77],{},"Example",[72,79,80],{},"Impact",[82,83,84,107,124,138],"tbody",{},[69,85,86,90,101],{},[87,88,89],"td",{},"Structural",[87,91,92,93,97,98],{},"A field renamed from ",[94,95,96],"code",{},"user_name"," to ",[94,99,100],{},"username",[87,102,103,104,106],{},"Code that reads ",[94,105,96],{}," breaks",[69,108,109,112,121],{},[87,110,111],{},"Content",[87,113,114,115,97,118],{},"A price changed from ",[94,116,117],{},"9.99",[94,119,120],{},"10.99",[87,122,123],{},"Business logic error",[69,125,126,129,135],{},[87,127,128],{},"Type change",[87,130,131,134],{},[94,132,133],{},"id"," changed from number to string",[87,136,137],{},"Serialization breaks",[69,139,140,143,146],{},[87,141,142],{},"Order change",[87,144,145],{},"Array items in different order",[87,147,148],{},"May or may not matter",[15,150,151],{},"Structural changes are usually more dangerous because they break code that depends on specific field names and types. Content changes may be intentional business updates.",[55,153,155],{"id":154},"key-fields-to-watch","Key Fields to Watch",[22,157,158,164,178,184,190],{},[25,159,160,163],{},[28,161,162],{},"Status codes"," — A 200 vs. 404 difference is critical",[25,165,166,169,170,173,174,177],{},[28,167,168],{},"Response headers"," — ",[94,171,172],{},"Content-Type"," or ",[94,175,176],{},"Cache-Control"," changes affect caching",[25,179,180,183],{},[28,181,182],{},"Nested objects"," — Deeply nested changes are easy to miss visually",[25,185,186,189],{},[28,187,188],{},"Array lengths"," — Missing or extra items indicate data issues",[25,191,192,169,195,198,199,202],{},[28,193,194],{},"Null vs. missing",[94,196,197],{},"{ \"field\": null }"," differs from a response that omits ",[94,200,201],{},"field"," entirely",[10,204,206],{"id":205},"methods-for-comparing-responses","Methods for Comparing Responses",[55,208,210],{"id":209},"raw-text-diff","Raw Text Diff",[15,212,213],{},"The simplest approach: copy both JSON responses into a diff tool and compare line by line.",[15,215,216,219,220,223],{},[28,217,218],{},"Pros",": Works for any text format, catches every difference\n",[28,221,222],{},"Cons",": Noisy — field order differences show as changes even when values are identical",[55,225,227],{"id":226},"normalized-json-diff","Normalized JSON Diff",[15,229,230],{},"Sort object keys alphabetically and pretty-print both JSONs before comparing. This eliminates false positives from key ordering.",[232,233,238],"pre",{"className":234,"code":235,"language":236,"meta":237,"style":237},"language-bash shiki shiki-themes github-light github-dark","# Normalize with jq\njq -S . response1.json > normalized1.json\njq -S . response2.json > normalized2.json\ndiff normalized1.json normalized2.json\n","bash","",[94,239,240,249,274,291],{"__ignoreMap":237},[241,242,245],"span",{"class":243,"line":244},"line",1,[241,246,248],{"class":247},"sJ8bj","# Normalize with jq\n",[241,250,252,256,260,264,267,271],{"class":243,"line":251},2,[241,253,255],{"class":254},"sScJk","jq",[241,257,259],{"class":258},"sj4cs"," -S",[241,261,263],{"class":262},"sZZnC"," .",[241,265,266],{"class":262}," response1.json",[241,268,270],{"class":269},"szBVR"," >",[241,272,273],{"class":262}," normalized1.json\n",[241,275,277,279,281,283,286,288],{"class":243,"line":276},3,[241,278,255],{"class":254},[241,280,259],{"class":258},[241,282,263],{"class":262},[241,284,285],{"class":262}," response2.json",[241,287,270],{"class":269},[241,289,290],{"class":262}," normalized2.json\n",[241,292,294,297,300],{"class":243,"line":293},4,[241,295,296],{"class":254},"diff",[241,298,299],{"class":262}," normalized1.json",[241,301,290],{"class":262},[15,303,304,306,307,309],{},[28,305,218],{},": Eliminates key-order noise\n",[28,308,222],{},": Manual step required; doesn't handle semantic differences",[55,311,313],{"id":312},"structural-comparison","Structural Comparison",[15,315,316,317,173,320,323,324,327,328,331],{},"Tools like ",[94,318,319],{},"json-diff-kit",[94,321,322],{},"deep-diff"," compare JSON semantically — they understand that ",[94,325,326],{},"{ \"a\": 1, \"b\": 2 }"," equals ",[94,329,330],{},"{ \"b\": 2, \"a\": 1 }"," and report only actual value differences.",[15,333,334,336,337,339],{},[28,335,218],{},": Semantic awareness, clean output\n",[28,338,222],{},": Requires a library or specialized tool",[10,341,343],{"id":342},"handling-common-challenges","Handling Common Challenges",[55,345,347],{"id":346},"dynamic-values","Dynamic Values",[15,349,350],{},"Timestamps, request IDs, and tokens change on every response. These create noise that drowns out real differences.",[15,352,353,356],{},[28,354,355],{},"Solution",": Mask dynamic fields before comparing. Replace known-volatile values with placeholders:",[232,358,362],{"className":359,"code":360,"language":361,"meta":237,"style":237},"language-javascript shiki shiki-themes github-light github-dark","function maskDynamic(obj) {\n  const masked = { ...obj }\n  masked.timestamp = '\u003CMASKED>'\n  masked.request_id = '\u003CMASKED>'\n  return masked\n}\n","javascript",[94,363,364,383,403,414,423,432],{"__ignoreMap":237},[241,365,366,369,372,376,380],{"class":243,"line":244},[241,367,368],{"class":269},"function",[241,370,371],{"class":254}," maskDynamic",[241,373,375],{"class":374},"sVt8B","(",[241,377,379],{"class":378},"s4XuR","obj",[241,381,382],{"class":374},") {\n",[241,384,385,388,391,394,397,400],{"class":243,"line":251},[241,386,387],{"class":269},"  const",[241,389,390],{"class":258}," masked",[241,392,393],{"class":269}," =",[241,395,396],{"class":374}," { ",[241,398,399],{"class":269},"...",[241,401,402],{"class":374},"obj }\n",[241,404,405,408,411],{"class":243,"line":276},[241,406,407],{"class":374},"  masked.timestamp ",[241,409,410],{"class":269},"=",[241,412,413],{"class":262}," '\u003CMASKED>'\n",[241,415,416,419,421],{"class":243,"line":293},[241,417,418],{"class":374},"  masked.request_id ",[241,420,410],{"class":269},[241,422,413],{"class":262},[241,424,426,429],{"class":243,"line":425},5,[241,427,428],{"class":269},"  return",[241,430,431],{"class":374}," masked\n",[241,433,435],{"class":243,"line":434},6,[241,436,437],{"class":374},"}\n",[55,439,441],{"id":440},"large-responses","Large Responses",[15,443,444],{},"APIs returning thousands of items make full comparison impractical.",[15,446,447,449],{},[28,448,355],{},": Compare a subset — first 10 items, or filter to specific records. Or compare only the schema (field names and types) instead of every value.",[55,451,453],{"id":452},"pagination","Pagination",[15,455,456],{},"Responses spanning multiple pages require careful handling.",[15,458,459,461],{},[28,460,355],{},": Fetch all pages first, merge into a single dataset, then compare. Or compare page-by-page if you only need to verify the pagination structure.",[10,463,465],{"id":464},"best-practices","Best Practices",[22,467,468,474,480,486,492],{},[25,469,470,473],{},[28,471,472],{},"Save baseline responses"," — Store a known-good response for each endpoint as a reference",[25,475,476,479],{},[28,477,478],{},"Automate comparisons"," — Run response diffs as part of your CI pipeline",[25,481,482,485],{},[28,483,484],{},"Use JSON Schema validation"," — Catch structural changes with schema checks before comparing values",[25,487,488,491],{},[28,489,490],{},"Document intentional changes"," — When an API change is deliberate, update your baseline and note the reason",[25,493,494,497],{},[28,495,496],{},"Compare headers too"," — Don't focus only on the body; headers affect caching, CORS, and content negotiation",[10,499,501],{"id":500},"key-takeaways","Key Takeaways",[22,503,504,507,510,513,516,519],{},[25,505,506],{},"Comparing API responses catches regressions, integration issues, and version differences early",[25,508,509],{},"Structural changes (renamed fields, type shifts) are more dangerous than content shifts",[25,511,512],{},"Normalize JSON before comparing to eliminate key-order noise",[25,514,515],{},"Mask dynamic values like timestamps and request IDs to reduce false positives",[25,517,518],{},"Save baseline responses and automate comparisons in your CI pipeline",[25,520,521],{},"Don't ignore response headers — they carry important behavioral signals",[10,523,525],{"id":524},"related-guides","Related Guides",[22,527,528,535,541],{},[25,529,530],{},[531,532,534],"a",{"href":533},"\u002Fguides\u002Ftext-diff-guide","Text Comparison Guide",[25,536,537],{},[531,538,540],{"href":539},"\u002Fguides\u002Fjson-path-syntax","JSON Path Syntax",[25,542,543],{},[531,544,546],{"href":545},"\u002Fguides\u002Fjson-schema-validation","JSON Schema Validation",[10,548,550],{"id":549},"try-it-yourself","Try It Yourself",[15,552,553,554,558],{},"Compare two API responses instantly with our free ",[531,555,557],{"href":556},"\u002Ftools\u002Fdiff-checker","Diff Checker",". Paste your JSON responses, see every structural and content difference highlighted, and copy the results — no setup required.",[560,561,562],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":237,"searchDepth":251,"depth":251,"links":564},[565,566,570,575,580,581,582,583],{"id":12,"depth":251,"text":13},{"id":52,"depth":251,"text":53,"children":567},[568,569],{"id":57,"depth":276,"text":58},{"id":154,"depth":276,"text":155},{"id":205,"depth":251,"text":206,"children":571},[572,573,574],{"id":209,"depth":276,"text":210},{"id":226,"depth":276,"text":227},{"id":312,"depth":276,"text":313},{"id":342,"depth":251,"text":343,"children":576},[577,578,579],{"id":346,"depth":276,"text":347},{"id":440,"depth":276,"text":441},{"id":452,"depth":276,"text":453},{"id":464,"depth":251,"text":465},{"id":500,"depth":251,"text":501},{"id":524,"depth":251,"text":525},{"id":549,"depth":251,"text":550},"2026-05-28","Learn how to compare API responses effectively to catch regressions, validate integrations, and debug unexpected behavior.","md",{"immutable":588},true,"\u002Fguides\u002Fcomparing-api-responses",{"title":5,"description":585},"guides\u002Fcomparing-api-responses","l7V2cMzNJeJ4gBTqqVZ4u4KsyIWpfxrUxXp3JyvMHZ0",1780401332360]