Quick answer
JSON allows duplicate keys in an object, but parsers typically keep only the last value.
JSON Duplicate Keys
JSON allows duplicate keys in an object, but parsers typically keep only the last value. Duplicate keys often indicate a mistake.
Common causes
- Building objects in a loop and reusing the same key.
- Merging objects without checking for existing keys.
- Manual editing that accidentally duplicated a key.
How to fix
- Search for repeated key names in your object.
- Use a validator or script to detect duplicate keys.
- Restructure data so each key appears once; use arrays if you need multiple values.
FAQ
- What happens with duplicate keys in JSON?
- Most parsers use the last occurrence; earlier values are overwritten. Behavior can vary.
- Is duplicate key valid JSON?
- Yes, it is valid per the spec, but it is usually a logic error.
Fix it now
Try in validator (prefill this example)