# Compare JSON objects without key-order noise

Canonical page: https://datalens.flazetech.in/guides/compare-json-objects

By [DataLens by Flazetech](https://datalens.flazetech.in/about).

A structural JSON diff compares parsed values rather than lines of text. Objects with the same properties and values compare equal even when their keys appear in a different order. DataLens reports added, removed and changed paths; array items are compared by index, so their order still matters.

[Open JSON diff](https://datalens.flazetech.in/json-diff)

## How to compare two JSON documents

Paste the original document on the left and the updated document on the right. Use Format both if compact payloads are difficult to read. Choose Compare JSON after both inputs are valid. The report identifies a path and shows the original and updated values beside it.

For an API regression check, use responses captured from the same request and review timestamps, generated identifiers and optional fields deliberately. A changed value can be expected behavior. The tool shows differences; it does not decide whether a change is a bug.

### Original JSON

```text
{"user":{"name":"Alex","active":false},"version":1}
```

### Updated JSON

```text
{"version":2,"user":{"active":true,"name":"Alex"}}
```

| Path | Original | Updated |
| --- | --- | --- |
| $.user.active | false | true |
| $.version | 1 | 2 |

## Does JSON object-key order matter?

DataLens ignores object-key order and whitespace. The two objects below compare equal because both contain a = 1 and b = 2. Sorting the input is unnecessary for this comparison. The same rule applies inside nested objects.

A text diff answers a different question: which characters or lines changed? Use one when indentation, original spacing or the source text itself matters. A structural comparison is useful when you care about the represented data.

### These objects compare equal

```text
{"a":1,"b":2}
{"b":2,"a":1}
```

Reference: [RFC 8259: objects are unordered; arrays are ordered](https://www.rfc-editor.org/rfc/rfc8259).

## Why does reordering a JSON array create differences?

Arrays are compared by position in DataLens. In the example below, index 0 changes from admin to editor and index 1 changes from editor to admin. Inserting an item near the start can shift many later positions and produce several reported changes.

This tool does not currently match array objects by an id field or ignore array order. If order is irrelevant in your application, normalize copies of both inputs using the same explicit rule before comparing. Keep the originals and account for duplicate values; do not silently treat every array as a set.

### A reordered array is different

```text
["admin","editor"]
["editor","admin"]
```

## Missing values, null and number types

A missing property and a property set to null are different. The number 1 and the string "1" are different too. These cases often explain a report that looks surprising at first glance. Review the value and its JSON type together, especially when a spreadsheet or API has converted numbers into strings.

| Original | Updated | Result in DataLens |
| --- | --- | --- |
| {} | {"note":null} | note is added |
| {"count":1} | {"count":"1"} | count changes type |
| {"active":false} | {"active":true} | active changes value |

## Use the difference report in a review

Copy or download the JSON report to attach a reproducible example to a bug report or code review. It contains paths, change types and before/after values. It is not an RFC 6902 JSON Patch document and should not be submitted to a patch API.

Comparison uses JavaScript values and number precision. Keep exact long numeric IDs as strings. When input is invalid, format and validate it first rather than comparing incomplete text. The report is computed in the browser; copying or downloading it does not create a public share link.

## Related tools

- [JSON formatter & validator](https://datalens.flazetech.in/json)
- [JSONPath tester](https://datalens.flazetech.in/jsonpath)
- [API client](https://datalens.flazetech.in/api)
