Duplicate property names in JSON
JSON does not forbid a repeated property name, and most parsers silently keep the last one. Here is why that is a problem and how to find them.
Open the JSON formatterWhat the error looks like
Different engines word this differently. You may see any of these:
Why it happens
- The JSON specification says names within an object should be unique, but it does not require a parser to reject a document that repeats one.
- In practice JSON.parse keeps the last occurrence and discards the earlier ones, silently.
- That silence is the danger: a configuration file with a repeated key does something different from what it appears to say, and nothing warns you.
Example
{
"timeout": 30,
"retries": 3,
"timeout": 60
}
{
"timeout": 60,
"retries": 3
}
How this tool reports it
The formatter reports duplicate property names as problems even though the document parses, and tells you which value actually survives. It is the one case where valid JSON is still worth flagging.
Paste your JSON into the formatter to see the exact line and column, or use the validator if you only need to check it.
Worth knowing
- Behaviour differs between languages. Some parsers raise an error, some keep the first occurrence rather than the last. Never rely on it.