JSON
JSON Diff / Compare
เปรียบเทียบเอกสาร JSON สองชุด — สิ่งที่เพิ่ม ลบ หรือเปลี่ยนแปลง พร้อมเส้นทางที่แน่นอนของแต่ละความแตกต่าง
Unlike a plain text diff, JSON Diff compares two documents by structure rather than by line: it understands that key order in an object doesn't matter, and it shows the exact path (e.g. user.address.city) to every difference.
How to use it
- Paste the original JSON into one field and the new version into the other.
- The result lists added, removed, and changed fields with the exact path to each and its old and new value.
- Formatting and key order don't affect the result — only the underlying data structure is compared.
Common uses
- Checking exactly what changed in an API response between two versions or two requests.
- Comparing configuration files (package.json, app settings) across branches or environments.
- Debugging a failing test by precisely comparing the expected and actual JSON output.
Things to keep in mind
Array elements are usually compared by position (index) — inserting one element near the start can show every following item as "changed", even though they merely shifted.
The comparison is structural, not textual — two JSON documents with identical data but different formatting or key order are treated as the same.
คำถามที่พบบ่อย
เครื่องมือนี้ตัดสินอย่างไรว่าอะไรคือ "ความแตกต่าง"?
มันเปรียบเทียบโครงสร้าง JSON ทั้งสองแบบซ้ำ ๆ ทีละคีย์และทีละดัชนี รายงานค่าที่เพิ่ม ลบ และเปลี่ยนแปลง — ลำดับคีย์ของ object ถูกละเว้น แต่ลำดับสมาชิกของ array มีความสำคัญ
ทำไมการสลับลำดับสมาชิกใน array ถึงแสดงเป็นการเปลี่ยนแปลง?
array ใน JSON มีลำดับ ดังนั้นสมาชิกที่ย้ายจากดัชนี 2 ไปดัชนี 0 จะถูกมองว่าเป็นการลบแล้วเพิ่มใหม่ ไม่ใช่ไม่มีการเปลี่ยนแปลง แม้ค่าจะเหมือนกันทุกประการ
ข้อมูล JSON ของฉันถูกส่งไปที่ไหนเพื่อคำนวณความแตกต่างหรือไม่?
ไม่ การเปรียบเทียบทำงานทั้งหมดในเบราว์เซอร์ของคุณ ไม่มีไฟล์ใดถูกอัปโหลดไปยังเซิร์ฟเวอร์
ลำดับคีย์ของ object มีผลต่อผลลัพธ์การเปรียบเทียบหรือไม่?
ไม่ การเปรียบเทียบเชิงโครงสร้างพิจารณาแค่ข้อมูลจริงเท่านั้น — ฟิลด์มีอยู่หรือไม่ ค่าอะไร และประเภทอะไร ลำดับคีย์ใน JSON object ไม่มีความหมายเชิงความหมาย จึงไม่ส่งผลต่อผลลัพธ์
สามารถเปรียบเทียบสมาชิกของอาร์เรย์ตามตัวระบุแทนตำแหน่งได้หรือไม่?
ขึ้นอยู่กับอัลกอริทึมการเปรียบเทียบที่ใช้ เครื่องมือ diff แบบง่ายจะเทียบสมาชิกอาร์เรย์ตามดัชนีเสมอ ส่วนเครื่องมือที่ซับซ้อนกว่าจะพยายามจับคู่ object ตามฟิลด์ร่วมอย่าง id เพื่อแสดงการแทรกหรือลบได้แม่นยำขึ้น