JSON Merge

Deep-merge multiple JSON objects with configurable strategies for conflicting keys, arrays (replace, concat, union), and null values.

How to Deep Merge JSON Objects Online

1

Paste Target & Source

Paste your base JSON object into the left editor and your override object into the right editor.

2

Configure Merge Strategy

Select your array merge strategy (Replace, Concat, or Union) and null value skipping rules.

3

Export Merged Result

Merges instantly in real time. Click Copy or Download to export combined JSON.

Tool Options

Array Strategies (Replace, Concat, Union)

Replace overrides target arrays entirely. Concat appends source items. Union merges unique values only.

Skip / Ignore Null Override Values

When enabled, null values in the source override payload do not overwrite existing values in the base object.

2 Spaces vs 4 Spaces Indentation

Formats the final merged JSON object structure with 2-space or 4-space indentation for optimal code readability.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the JSON Merge Tool do?

The JSON Merge Tool performs deep, recursive merging of two or more JSON objects into a single unified JSON document in real time. Executing 100% in-browser on blueutils.com, it merges nested object trees without overwriting sibling keys, providing configurable strategies for array reconciliation (replace, concat, union), null value overrides (skipNull), and custom indentation.

  • Real-Time Zero-Latency Merging: Merges baseline and override JSON payloads as you type with live key metrics (X Keys).
  • Array Resolution Strategies: Select Replace (overwrite target arrays), Concat (append items), or Union (deduplicate values).
  • Null Safety: Enable Skip Nulls to prevent null fields in patch objects from overwriting existing baseline properties.

Core Concepts & Technical Specifications

  1. Recursive Deep Merging vs. Shallow Assignment:
    • Shallow Merge (Object.assign): Overwrites entire nested child objects with the incoming source object.
    • Deep AST Merging: Recursively traverses nested keys down to primitive leaves, merging sibling branches while cleanly replacing or joining leaves.
  2. Array Conflict Strategies:
    • replace: Replaces target arrays entirely with the override array.
    • concat: Concatenates source array elements to the end of the base array.
    • union: Concatenates arrays and performs deep value deduplication using structural hashing.
  3. In-Browser Privacy:
    • All recursive object merge algorithms execute locally in browser memory.
    • No data is transmitted to external servers, logged, or retained.

How to use the tool?

  1. Input Baseline & Override JSON:
    • Paste your base target JSON object into the left editor and your override patch object into the right editor, or click Sample.
  2. Configure Strategy & Indentation:
    • Choose your Array Strategy (Replace Arrays, Concat Arrays, or Deduplicate Union), toggle Skip Nulls, and select your indentation (2 Spaces, 4 Spaces, Tab, or Custom).
  3. Copy or Download:
    • Merged JSON appears instantly in the bottom editor. Click Copy to copy to your clipboard or Download to save as output.json.

Pipeline & Contextual Workflows

  • Configuration Layering: Merge base application configurations (config.default.json) with environment overrides (config.production.json).
  • Structural Diffing: Inspect merged differences side-by-side using JSON Diff Tool.
  • TypeScript Generation: Generate typed interfaces from merged schemas using JSON to TypeScript Converter.

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/json/merge) for automated CI/CD config generation, Kubernetes manifest patching, and data pipelines.

API Request Parameters

Name Type Description Example
jsonSources / sources / left & right Array / Objects Array of raw JSON strings or JSON objects to merge sequentially. [{"a":1},{"b":2}]
arrayStrategy String Array merge preference ("replace", "concat", "union"). Defaults to "replace". "union"
skipNull Boolean Ignore null values in override objects. Defaults to false. true
indent Number Indentation spaces for formatted JSON output. Defaults to 2. 2

API Request Payload Examples

cURL (Using Direct JSON Objects & Union Array Strategy)

curl -X POST https://blueutils.com/api/json/merge \
  -H "Content-Type: application/json" \
  -d '{
    "jsonSources": [
      {
        "appName": "Blueutils",
        "settings": { "timeout": 5000 },
        "tags": ["dev"]
      },
      {
        "settings": { "debug": true },
        "tags": ["tools"]
      }
    ],
    "arrayStrategy": "union",
    "skipNull": false,
    "indent": 2
  }'

cURL (Using Left / Right Aliases)

curl -X POST https://blueutils.com/api/json/merge \
  -H "Content-Type: application/json" \
  -d '{
    "left": { "version": "1.0.0", "active": true },
    "right": { "version": "2.0.0" },
    "arrayStrategy": "replace"
  }'

Python

import requests

url = "https://blueutils.com/api/json/merge"
payload = {
    "jsonSources": [
        {"appName": "Blueutils", "settings": {"timeout": 5000}},
        {"settings": {"debug": True}}
    ],
    "arrayStrategy": "concat",
    "skipNull": False,
    "indent": 2
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "jsonSources": [
                    {"appName": "Blueutils", "settings": {"timeout": 5000}},
                    {"settings": {"debug": true}}
                ],
                "arrayStrategy": "replace",
                "skipNull": false,
                "indent": 2
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/json/merge"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Returns true if JSON merge succeeded. true
result String Formatted JSON string of the deep-merged object. "{\n \"appName\": \"Blueutils\"\n}"
mergedObject / data Object Parsed JavaScript object of the merged result. {"appName":"Blueutils"}
originalSize Number Total combined byte size of all input sources in UTF-8. 92
resultSize Number Byte size of the merged JSON result in UTF-8. 112
keyCount Number Total number of properties in the merged root object. 2
error String Detailed error explanation returned on invalid syntax. "Invalid JSON syntax in source #1 (Line 2)"

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "mergedObject": {
    "appName": "Blueutils",
    "settings": {
      "timeout": 5000,
      "debug": true
    }
  },
  "data": {
    "appName": "Blueutils",
    "settings": {
      "timeout": 5000,
      "debug": true
    }
  },
  "result": "{\n  \"appName\": \"Blueutils\",\n  \"settings\": {\n    \"timeout\": 5000,\n    \"debug\": true\n  }\n}",
  "originalSize": 92,
  "resultSize": 112,
  "keyCount": 2
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "At least two JSON objects are required for merging."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to merge JSON?

Automating JSON object merging streamlines multi-environment infrastructure:

  • Configuration Layering: Merges baseline manifests with cluster-specific patches in CI/CD deployment pipelines.
  • LLM Context Optimization: LLMs can output focused delta patches; calling the API combines the patch with the base object without token hallucination.
  • Deterministic Array Merging: Guarantees deterministic array union deduplication and key precedence across batch jobs.

Native Usage

Deep-merge JSON objects locally across terminal environments and programming runtimes:

Linux / macOS (jq)

# Using jq CLI to deep-merge JSON files
jq -s '.[0] * .[1]' f1.json f2.json

Windows (PowerShell)

# Deep-merge JSON files using Node.js in PowerShell
node -e "const deepmerge=(t,s)=>{for(let k of Object.keys(s)){if(s[k] instanceof Object&&k in t)Object.assign(s[k],deepmerge(t[k],s[k]));}Object.assign(t||{},s);return t;}; const f1=JSON.parse(require('fs').readFileSync('f1.json')); const f2=JSON.parse(require('fs').readFileSync('f2.json')); console.log(JSON.stringify(deepmerge(f1,f2),null,2));"

Python

import json

def deep_merge(dict1, dict2):
    result = dict1.copy()
    for key, value in dict2.items():
        if isinstance(value, dict) and key in result and isinstance(result[key], dict):
            result[key] = deep_merge(result[key], value)
        else:
            result[key] = value
    return result

with open("f1.json") as f1, open("f2.json") as f2:
    doc1 = json.load(f1)
    doc2 = json.load(f2)

merged = deep_merge(doc1, doc2)
print(json.dumps(merged, indent=2))

Java (Jackson)

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;

public class Main {
    public static void main(String[] args) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode mainNode = mapper.readTree(new File("f1.json"));
        JsonNode updateNode = mapper.readTree(new File("f2.json"));

        JsonNode merged = mapper.readerForUpdating(mainNode).readValue(updateNode);
        System.out.println(merged.toPrettyString());
    }
}

Frequently Asked Questions (FAQ)

How does deep merging JSON work?

Deep merging combines properties from multiple JSON objects. Nested object keys are merged recursively rather than completely overwritten.

What array merge strategies are supported?

We support three array strategies: Replace (override baseline arrays), Concat (append new items), and Union (merge unique elements only).

How does the Skip Nulls option work?

When Skip Nulls is enabled, null values in the override patch object will not erase or overwrite existing keys in the base target object.

Can I merge more than two JSON objects simultaneously?

Yes. Via our REST API (/api/json/merge), you can pass an array of unlimited JSON source objects to merge sequentially from left to right.

Is my JSON data uploaded or stored remotely when merging?

No. All deep-merge operations and JSON parsing run 100% client-side directly inside your browser. Your JSON data is never uploaded or saved remotely.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.