Duplicate Keys in JSON
The JSON specification does not explicitly forbid duplicate keys, but it strongly discourages them. When duplicate keys exist, most parsers silently keep only the last value and discard earlier ones. This leads to data loss that is extremely hard to debug.
Why It Matters
Data is silently lost without any error or warning. If you have two properties named 'email', only the last one is kept. This can cause security issues, configuration bugs, and data corruption that goes unnoticed for a long time.
Code Examples
{
"name": "John",
"email": "john@work.com",
"age": 30,
"email": "john@personal.com"
}{
"name": "John",
"workEmail": "john@work.com",
"personalEmail": "john@personal.com",
"age": 30
}How to Fix
- 1Search for duplicate key names in your JSON document.
- 2Rename duplicate keys to be unique and descriptive.
- 3If you need multiple values for a concept, use an array instead.
- 4Use a JSON linter that warns about duplicate keys, since most parsers silently accept them.
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated JSON APIs on reliable hosting.
Related JSON Errors
Unquoted Property Keys in JSON
JSON requires all property names to be wrapped in double quotes. Learn how to fix unquoted key errors.
Missing Comma Between Properties
Learn how to fix the missing comma error in JSON. Every property pair must be separated by a comma.
Unexpected Token in JSON
Learn why JSON throws an unexpected token error and how to fix it. Common causes include trailing commas, single quotes, and unquoted keys.