toolqik

125 · JSON

JSON Duplicate Key Checker

Find keys that appear more than once in a JSON object, with line numbers.

Runs in your browser
Clean output keeps
Indent
    JSON without duplicates
    
      

    About this tool

    Duplicate keys are one of the sneakiest JSON bugs. {"port": 8080, "port": 9090} is accepted by almost every parser without an error, but each parser picks a winner differently: JavaScript’s JSON.parse and Python’s json module keep the last value, some libraries keep the first, and strict parsers reject the document. The result is config that behaves differently in different services. This tool finds every duplicate key and shows exactly where it is.

    How to check for duplicate keys

    1. Paste JSON or drop a file. The JSON must be valid; syntax errors are reported with their position.
    2. Each duplicate is listed with its path (such as $.database.host), how many times it appears, and the line and column of every occurrence.
    3. The output shows the same JSON with duplicates removed. Choose whether to keep the last value (what JSON.parse would use) or the first.

    Why you can’t find duplicates by formatting

    Formatters and viewers parse the JSON first, and parsing is exactly where duplicates disappear. Once parsed, only one value is left, so the duplicate is invisible. This checker reads the original text, so it sees every occurrence. Keys are compared after decoding escapes, so "name" and "\u006eame" count as the same key.

    Where duplicates come from

    • Hand-edited config files where a setting was added again further down.
    • Merge conflicts resolved by keeping both sides.
    • Code that builds JSON by string concatenation instead of a serializer.
    • Templates (Helm, Jinja, Terraform) that render the same key from two places.

    To catch them in code, Python can reject duplicates with json.loads(text, object_pairs_hook=…), and Go’s encoding/json v2 rejects them by default. Running this check in review is the quickest fix for config files.

    FAQ

    Does JSON allow duplicate keys?

    RFC 8259 says object keys SHOULD be unique, but does not forbid duplicates, so most parsers accept them. Behaviour then varies, which is why duplicates should be treated as errors.

    Which value does JSON.parse keep for a duplicate key?

    The last one. {"a": 1, "a": 2} parses to {"a": 2} in JavaScript, and Python’s json module does the same.

    Why doesn’t my JSON formatter show duplicate keys?

    Formatters parse the JSON, and parsing keeps only one value per key, so the duplicate is gone before it is displayed. This tool reads the raw text instead.

    How do I remove duplicate keys from JSON?

    Paste the JSON here and copy the output, which keeps one value per key. Choose whether the first or last occurrence wins.

    Are keys in different objects duplicates?

    No. The same key in different objects, such as "id" in every item of an array, is normal. Only repeats inside one object are reported.

    esc
    ↑↓ navigate↵ open