JSON WalletPrivacy-first JSON & API workspace

Fix Duplicate Keys in JSON

All languages ยท JSON error

โ† All tools

Duplicate key in JSONDuplicate object keyA value was overwritten by a later duplicate key

Opens the editor with a broken example loaded and repaired, entirely in your browser โ€” nothing is uploaded.

What causes it

The JSON specification says object keys should be unique but does not require parsers to reject duplicates. In practice, almost every parser keeps the last occurrence and silently discards the earlier ones. That makes duplicate keys dangerous: there is no error, just missing data.

Duplicates usually creep in when JSON is assembled from templates or by concatenation, or when two code paths both write the same field. A few strict validators and linters will flag them, which is why you might see a "duplicate key" warning.

How to fix it

  1. Scan the object for two entries with the same key name.
  2. Decide which value is correct and delete the other โ€” or rename one key if both are needed.
  3. If the JSON is generated, fix the code path that writes the field twice.
  4. Paste it into JSON Wallet and use the tree view to spot repeated keys at each level.

Before and after

Broken:

{
  "id": 1,
  "name": "Ada",
  "id": 2
}

Fixed:

{
  "id": 2,
  "name": "Ada"
}

Want to fix your own JSON instead of the example? Open the editor, paste it in, and click Repair โ€” it runs entirely in your browser.

Frequently asked questions

Do duplicate keys throw an error?

Usually not. Most parsers accept them and keep the last value, so the earlier ones vanish without warning. That silent data loss is exactly why duplicates are a bug worth hunting.

Which value wins when a key is duplicated?

In virtually all common parsers (JavaScript, Python, Go, and others) the last occurrence wins. But relying on that is fragile โ€” make keys unique instead.


Related JSON errors

For a full reference of JSON mistakes, read Common JSON errors and how to fix them.

Press โŒ˜ K for commands