Skip to content
🛠️ToolsShed

JSON Merge Tool

Deep merge multiple JSON objects into one with conflict resolution options.

JSON Object #1
JSON Object #2

About this tool

The JSON Merge Tool combines multiple JSON objects into a single unified structure using deep merging, which means nested objects and arrays are intelligently combined rather than simply overwritten. This is essential for developers working with configuration files, API responses, or data aggregation workflows where you need to combine data from different sources while preserving meaningful information from each input.

To use the tool, paste your JSON objects into the input fields, select your preferred merge strategy (such as overwrite, array concatenation, or deep merge), and click the merge button. The tool handles nested structures automatically, resolving conflicts according to your chosen strategy. Common use cases include merging environment configurations, combining API payloads, consolidating settings from multiple services, and integrating test fixtures or mock data.

The tool works entirely in your browser, so your JSON data never leaves your computer, making it safe for sensitive configurations. Keep in mind that the merge behavior depends on your chosen strategy—understand whether you want nested objects combined, arrays appended, or values replaced to achieve the exact result you need.

Frequently Asked Questions

Code Implementation

import json
from copy import deepcopy

def deep_merge(base: dict, override: dict, strategy: str = "last_wins") -> dict:
    """
    Deep merge two dicts.
    strategy: 'last_wins' | 'first_wins' | 'array_concat'
    """
    result = deepcopy(base)
    for key, value in override.items():
        if key in result:
            if isinstance(result[key], dict) and isinstance(value, dict):
                result[key] = deep_merge(result[key], value, strategy)
            elif isinstance(result[key], list) and isinstance(value, list) and strategy == "array_concat":
                result[key] = result[key] + value
            else:
                if strategy != "first_wins":
                    result[key] = deepcopy(value)
        else:
            result[key] = deepcopy(value)
    return result

# Example
a = {"name": "Alice", "scores": [1, 2], "meta": {"v": 1}}
b = {"name": "Bob",   "scores": [3, 4], "meta": {"v": 2, "new": True}}

print(json.dumps(deep_merge(a, b, "last_wins"),   indent=2))
print(json.dumps(deep_merge(a, b, "first_wins"),  indent=2))
print(json.dumps(deep_merge(a, b, "array_concat"),indent=2))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.