JSON Merge

Deep-merge two JSON objects into one; conflicting keys default to the right value (switchable, or report the conflict count only), arrays are replaced as a whole.

JSON A
Drop a file here
or click the button below to choose a local file
.json / .txt / .csv, up to 10 MB, parsed locally in your browser
JSON B
Drop a file here
or click the button below to choose a local file
.json / .txt / .csv, up to 10 MB, parsed locally in your browser
Everything runs locally in your browser. No data is uploaded.

Deep-merge two JSON documents and handle duplicate fields by strategy

What is JSON Merge?

JSON Merge combines two JSON documents into a single result by field. Unique fields from JSON A and JSON B are preserved, while duplicate fields are handled according to the selected merge strategy. When duplicate values are both objects, deep merge continues into their nested fields.

How does JSON deep merge handle nested objects?

This tool uses deep merge by default. For nested objects, an outer field with the same name does not cause B to replace the entire object from A. Instead, the merge continues into the nested fields. For example, if A contains server.port and B contains server.host, both fields are preserved in the result. Only values that conflict at the same path are handled by the selected strategy. When deep merge is disabled, duplicate fields are taken as whole values instead of being compared recursively.

What are the three strategies for duplicate fields?

With last-wins, the value from JSON B takes precedence. This is the default strategy and is useful when B should override default configuration in A. With first-wins, the value from JSON A takes precedence, while B only adds fields that do not already exist in A. With conflict-preserve-left, conflicting fields keep the value from A while the number of conflicts is counted, making it easier to review potential overwrite risks.

How are arrays merged?

Arrays are handled as complete values rather than merged element by element by index. If A and B both contain an array at the same path, the result selects one of the arrays according to the current first-wins or last-wins strategy. The two arrays are not automatically concatenated or merged by index. This avoids unexpected combinations when working with ordered lists.

What counts as a conflict?

A field is counted as a conflict when JSON A and JSON B both contain a value at the same field path, the values are different, and the merge strategy must determine which value to keep. Identical values are not counted as conflicts. Duplicate fields inside nested objects are handled according to their actual paths. After merging, you can review the conflict count and check important configuration values.

What is JSON Merge useful for?

JSON Merge is useful for combining default and environment-specific configurations, configuration files from different environments, API defaults and user settings, and JSON data maintained in separate batches. When you first need to understand exactly what changed, use JSON Diff to review added, removed, and changed fields before merging.

How to merge local JSON files

Switch to the file upload tab and place the first file in JSON A and the second file in JSON B, or drag local JSON files directly into the page. Files are read and processed in the browser, with a 10 MB limit per file. Once both sides are loaded, you can merge them without uploading their contents to the server. The swap button exchanges A and B because their order affects overwrite results.

How to check the result after merging

After the merge is complete, first review the number of conflicting fields and then check the final values of important fields. If you use last-wins, pay particular attention to whether the values from JSON B are correct. With first-wins, check whether the original values from A should be preserved. The generated JSON can be copied or downloaded. Results use two-space indentation for easier reading and version management.

How are duplicate fields handled in JSON Merge?

JSON Merge uses deep merge by default: unique fields are preserved, nested objects are merged recursively, and duplicate fields are overwritten by JSON B. You can also switch to JSON A taking precedence or preserve the left value for conflicts while counting the conflicts.

Arrays are handled as complete values rather than merged by index. The merge order is A first and B second, so swapping the two inputs can change the final value of conflicting fields.

  • Deep-merges two JSON documents, preserving unique fields and recursively merging nested objects; deep merge can be disabled
  • Duplicate fields support last-wins, first-wins, and conflict-preserve-left strategies with conflict counting
  • Arrays are handled as complete values rather than merged by index or automatically concatenated
  • The conflict count is shown after merging to help review overwrite risks
  • Supports text and local JSON files with a 10 MB limit per file
  • Processing runs locally in the browser, and JSON content is not uploaded to the server
If you need to identify which fields changed before merging two JSON documents, use JSON Diff first. If you need to convert the merged JSON into a table, use JSON → CSV.
Comments 0
No comments yet. Be the first to comment!
avatar
Comment content cannot be empty
0/255