JSON Duplicate Key Checker

JSON.parse silently keeps the last value when a key is repeated. The checker walks every object and tells you exactly where the duplicates live.

JSON Duplicate Key Finder

Detect duplicate keys that can cause data loss

Instant Scan

Detect duplicates in milliseconds

100% Private

All processing happens in your browser

No Signup

Free tool, no registration required

Duplicate JSON Keys: A Silent Data Corruption Problem

The JSON specification (RFC 8259) states that object key names "SHOULD be unique" — it's a recommendation, not a hard requirement. This means JSON with duplicate keys is technically valid text that most parsers will accept without error. The danger: different parsers handle duplicates differently. Some keep the first value, some keep the last, and some return both. You can write JSON with duplicate keys and it will parse successfully — but silently give you different data depending on which library is reading it.

Real-World Impact

Duplicate keys cause bugs that are extremely hard to track down because the JSON appears valid and the parser reports no error. Imagine a security check: {"admin": false, "admin": true}. One parser sees the first value (not admin), another sees the second (admin). This class of vulnerability has been exploited in real-world JWT and access control bypasses by sending duplicate keys to exploit parser disagreements between a validation layer and an execution layer. Beyond security, duplicate keys from code generation bugs or hand-editing often silently drop data.

Where Duplicates Come From

The most common sources of duplicate JSON keys: hand-editing a JSON file and accidentally adding a key twice, code generation bugs that emit the same field from multiple code paths, merging two JSON objects using string concatenation instead of proper object merging, and legacy APIs that were poorly designed. Linters and JSON schema validators may not catch duplicates unless explicitly configured to do so.

How to Use This Tool

Paste your JSON to scan for duplicate keys at any depth. The tool reports every duplicate key with its path, so you can locate and fix each one. Fixing duplicates before storing or transmitting JSON prevents silent data corruption downstream.

Frequently Asked Questions

Instant

Runs entirely in your browser — no upload, no wait.

100% private

Your JSON never leaves the tab. Nothing is logged.

No signup

Free, unlimited, no account required.

The silent JSON bug

JSON technically allows duplicate keys (the spec only says behavior is "implementation-defined"). Every mainstream parser keeps the last occurrence. The result: data loss with no warning. The checker scans your document and reports each duplicate with its full JSON Pointer path.

This matters for security as well as correctness. Parser differentials — where one layer of your stack keeps the first value and another keeps the last — have been exploited in JWT and access control bypasses. An authentication middleware might read the first `role` key ("user"), while the downstream service reads the second ("admin"). Validating your JSON for duplicate keys before storing or forwarding it closes this class of vulnerability.

How duplicates sneak in

Most often via concatenation — merging two API responses, hand-editing a config, or copying a block of keys without noticing one of them already exists. Code generators occasionally emit duplicates when two source schemas map to the same JSON property. Template engines that build JSON by string interpolation are another common source: if two different template blocks both emit the same key, the output JSON has a duplicate with no syntax error and no runtime warning.

Legacy codebases that serialize objects with reflection or custom serializers sometimes produce duplicates when a field is annotated with multiple names for backwards compatibility. Import pipelines that merge JSON from multiple upstream sources can produce duplicates at the merge boundary. The checker detects all of these cases regardless of source.

Reading the report

Each row shows the offending key, the JSON Pointer to the parent object, the values that would be lost, and a quick action to keep the first or the last occurrence. For complex nested structures, the JSON Pointer path (e.g. `/data/users/3/permissions`) precisely locates the duplicate within a large document, letting you navigate directly to it rather than searching manually.

CI integration

For automated checks, ajv with allowUnionTypes: false and a custom keyword can flag duplicates at validation time. For raw text scanning, the snippet below is enough.

// Lossless reviver — collects duplicates instead of dropping them
const seen = [];
JSON.parse(input, function (key, value) {
  if (this && Object.prototype.hasOwnProperty.call(this, key) && seen.indexOf(this) === -1) {
    seen.push(this);
  }
  return value;
});

Privacy

All scanning happens in the browser. No upload, no telemetry.

Related tools

Frequently asked questions