# Online JSON5 Diff: Compare Two Files by Data | JSON5.dev


Source: https://json5.dev/tools/online-diff/

---

# Online Diff: JSON5

Compare two JSON5 or JSON files by their data, not by their text.

A text diff of two config files is noisy. One file has comments, the other does not. One writes `0x1F90`, the other `8080`. The keys are in a different order. None of that changes what a program reads, and a line-by-line diff reports all of it.

This tool parses both texts with the reference JSON5 parser and compares the values. You get one row for each value that was added, removed or changed, with its path. Everything runs locally in your browser, which matters for config files that hold hosts, keys or tokens.

![Two config files side by side with one changed value and one added key highlighted](https://json5.dev/img/hero/tools-online-diff.png)

**TL;DR:** Paste one file on the left and one on the right. Comments, key order, quote style, trailing commas, white space and number spelling are ignored. Only real differences in the data are listed: added, removed and changed values, each with its path.

## Compare Two JSON5 Files

Two samples are loaded: a commented JSON5 file and a JSON file with the keys in another order. They differ in three places.

Left (before) 

Right (after) 

  

**Private by design:** both texts are parsed and compared in your browser. They are never uploaded, logged or sent to any server, and they are gone when you close the tab. Open file and drag and drop read the file inside your browser. Copy link puts both texts in the part of the address after the # sign, which browsers do not send to any server.

![Hidden icon](https://json5.dev/images/icons/hidden.png)

## What Is Ignored and What Is Compared

Both texts are turned into values first, so anything that is only spelling disappears before the comparison starts.

Difference in the text

Reported?

Why

Comments added, removed or reworded

No

Comments are not data

Keys in a different order

No

Object members have no order

`'text'` against `"text"`, `key` against `"key"`

No

Same string, same key

`0x1F90` against `8080`, `.5` against `0.5`, `+1` against `1`, `1e3` against `1000`

No

Same number

Trailing commas, indentation, line breaks

No

Not data

Array items in a different order

Yes

Arrays are ordered; items are compared by position

`1` against `"1"`, `null` against a missing key

Yes

Different types, or present against absent

Each row in the result starts with a label and a path. **changed** shows the old value, an arrow and the new value. **added** is a value that exists only on the right. **removed** is a value that exists only on the left. A path such as `limits.retries` or `regions[2]` tells you where the value sits. Long values are shortened to 80 characters.

The comparison uses `microdiff`, an open source library (MIT license) that is bundled into this page.

![Code icon](https://json5.dev/images/icons/code.png)

## Worked Example

The left sample is a hand-written JSON5 config:

`{ // staging name: 'orders-api', port: 0x1F90, regions: ['us-east', 'eu-west',], limits: { timeoutMs: 30000, retries: 3, }, }`

The right sample is machine-written JSON with the keys sorted:

`{ "limits": { "retries": 5, "timeoutMs": 30000 }, "name": "orders-api", "port": 8080, "regions": ["us-east", "eu-west", "ap-south"], "tls": true }`

A text diff marks every line as changed. The tool reports three differences:

`changed limits.retries: 3 -> 5 added regions[2]: 'ap-south' added tls: true`

The port is not listed, because `0x1F90` and `8080` are the same number. The comment and the key order are not listed either.

![Idea icon](https://json5.dev/images/icons/idea.png)

## When to Use It

-   **Checking a migration.** After moving a file from JSON to JSON5 and adding comments, confirm the data did not change. "No differences" is the proof. The [migration tutorial](https://json5.dev/tutorials/migration-from-json/) covers the rest.
-   **Comparing environments.** Put the staging config on the left and production on the right to see only the settings that differ.
-   **Reviewing a generated file.** Compare a hand-written source with the JSON a build step produced from it.
-   **Checking a formatter or converter.** Run a file through the [formatter](https://json5.dev/tools/online-formatter/) or the [converter](https://json5.dev/tools/online-converter/) and compare the result with the original.

Two limits are worth knowing. Array items are matched by position, so inserting one item at the start of a long array reports every later item as changed. And numbers are read as IEEE 754 doubles, so two integers above 9007199254740991 that differ only in their last digits can compare as equal.

## FAQ

### Can I compare a JSON5 file with a JSON file?

Yes. Every JSON document is valid JSON5, so both boxes accept either format, and the comparison is on the parsed values.

### Does key order matter?

No. Objects are compared key by key, wherever each key appears in the text.

### Why does it say there are no differences when the files look different?

Because they hold the same data. Comments, quotes, commas, [white space](https://json5.dev/glossary/#white-space), key order and the way a number is written do not change the parsed value.

### What happens if one side does not parse?

The status line says which side failed and shows the parser message with the line, column and surrounding lines. Fix that side and the comparison runs again.

### Are my files uploaded?

No. Both texts stay in your browser tab. Nothing is transmitted or stored.

## See Also

[

### Online Validator

Check syntax with line numbers

](https://json5.dev/tools/online-validator/)[

### Online Viewer

Explore one file as a tree

](https://json5.dev/tools/online-viewer/)[

### Migrating From JSON

Step-by-step adoption

](https://json5.dev/tutorials/migration-from-json/)

## More Online Tools

Check a file against a schema, or fix one that will not parse.

[Schema Validator](https://json5.dev/tools/online-schema-validator/) [Online Repair](https://json5.dev/tools/online-repair/)
