Skip to main content

How to Compare Two JSON Files

By Junaid Khan ·

Comparing a minified JSON export against a formatted one can make a one-value edit look like a full rewrite. Format both copies the same way first so the line comparison has a consistent starting point.

Steps

  1. Format both copies

    Open JSON Formatter in two tabs. Paste the earlier JSON in one and the revised JSON in the other. Format both with the same indentation setting. If one fails to parse, check for misplaced commas or quotation marks before continuing.

  2. Compare the formatted text

    Open Diff Checker and put the old formatted text in Original (Before) and the new text in Modified (After). Use the line view to locate changed settings and the word view when you want smaller changes within a line.

  3. Read each changed value in context

    Look at the surrounding keys to tell where the value lives in the document. For example, changing a port from the number 8080 to the string "8080" can matter even though the digits match.

Separate reordering from value changes

Diff Checker compares text. If an object’s keys moved, review whether their values changed as well. If items in an array moved, keep their order in the comparison because position can matter to the program that reads the file.

Save the original copies separately from the formatted ones when debugging an import. That lets you reproduce the input exactly if a parser or a downstream service reports an error.

When the line view is mostly red, format both files again with the same indent and compare a second time before you treat the change as real. A difference in key order inside one object is not the same as a changed value, so read the key name on that line. Numbers and strings that look alike, such as 8080 and "8080", are different to a program. Keep the two original files, and use the formatted copies only for the comparison, so you can repeat the check if a parser later rejects the import.