Merge JSON Files Online

Combine multiple JSON files into one valid result. Reorder files, control array and key conflicts, preview the output, and download it without uploading your data.

Before & After

Input: Two Config Files
json
// config_base.json
{
  "app": "MyApp",
  "database": {
    "host": "localhost",
    "port": 5432
  },
  "features": ["auth", "logging"]
}

// config_prod.json
{
  "database": {
    "host": "db.prod.com",
    "ssl": true
  },
  "features": ["caching"],
  "replicas": 3
}
Output: Merged Result
json
{
  "app": "MyApp",
  "database": {
    "host": "db.prod.com",
    "port": 5432,
    "ssl": true
  },
  "features": ["auth", "logging", "caching"],
  "replicas": 3
}

How It Works

1

Add your files

Drop .json files or browse. Each file is checked as it loads.

2

Choose settings

Set how arrays, conflicting keys, numbers and strings merge.

3

Download

Copy the merged JSON or download it as a file.

Programmatic Merge

Pythonmerge_json.py
import json

# Load both JSON files
with open("config_base.json") as f1, open("config_prod.json") as f2:
    base = json.load(f1)
    overrides = json.load(f2)

# Shallow merge (overrides win)
merged = {**base, **overrides}

with open("merged.json", "w") as out:
    json.dump(merged, out, indent=2)
Node.jsmerge.js
const fs = require("fs");
const _ = require("lodash");

const file1 = JSON.parse(fs.readFileSync("users_a.json"));
const file2 = JSON.parse(fs.readFileSync("users_b.json"));

// Deep merge - nested objects are combined, not replaced
const merged = _.merge({}, file1, file2);

fs.writeFileSync("merged.json", JSON.stringify(merged, null, 2));
Bash (jq)terminal
# Deep merge two JSON files with jq (one-liner)
jq -s '.[0] * .[1]' config_base.json config_prod.json > merged.json

# Concatenate two JSON arrays
jq -s '.[0] + .[1]' users_a.json users_b.json > all_users.json

# Merge multiple files at once
jq -s 'reduce .[] as $item ({}; . * $item)' *.json > merged.json

FAQ

Complete Guide

Array merge vs object merge - picking the right strategy

Array merge appends all items from both arrays into one array. Use this for datasets, logs, and lists where you want every record from both files. Example: [1, 2, 3] + [4, 5, 6] = [1, 2, 3, 4, 5, 6]. If the combined dataset ends up too large for the system you're sending it to, break it back into smaller files with the JSON File Splitter.

Object merge combines keys from both objects into one object. Use this for config files and settings where you want keys from both sources. Example: {"a": 1} + {"b": 2} = {"a": 1, "b": 2}.

Deep merge recursively combines nested objects instead of overwriting the whole parent key. Use this when both files have the same nested keys with different sub-values. Example: {"db": {"host": "localhost"}} + {"db": {"port": 5432}} = {"db": {"host": "localhost", "port": 5432}}.

The tool defaults to deep merge for objects and concatenation for arrays. To change array behavior, open Merge settings and pick an Array Strategy: Overwrite keeps only the later array, Merge Unique drops repeated primitive values (strings, numbers, booleans; objects are not compared), and Merge by Key combines objects that share the same value for a key such as id, with later fields winning. Objects without that key are kept as they are.

Merging JSON files with conflicting keys

When both files have the same key with different values, the file later in the list wins by default. If you upload file1.json with {"name": "Alice"} and then file2.json with {"name": "Bob"}, the output will be {"name": "Bob"}.

Deep merge handles nested conflicts by going level by level. If both files have database.host but different values, the second file's value wins for that specific nested key while preserving other keys in the database object.

You can change how conflicting values are combined in Merge settings. With Conflict Resolution set to Merge Values, Number Handling can Sum Numbers (5 + 3 = 8) and String Handling can Concatenate ("ab" + "cd" = "abcd"). Arrays at the same key follow the Array Strategy. Rules the tool doesn't offer, such as keeping the higher value or choosing values by hand, need code; the Python example above is a starting point.

How the tool handles invalid JSON

The tool validates each file as soon as you add it. A file with invalid JSON is marked in the file list with your browser's parser error, for example "Expected ',' or '}' after property value in JSON at position 214". Most current browsers also report the line and column. Invalid files are skipped when you merge, and the tool tells you how many were left out.

Common causes: trailing commas (valid in JavaScript, not in JSON), unquoted keys like {name: "Alice"} instead of {"name": "Alice"}, and single quotes instead of double quotes.

Fix the error in a text editor first, then re-upload. The tool won't attempt to auto-correct invalid JSON because that could silently corrupt your data.

Need a JSON Editor?

After merging files, open the result in a JSON editor if you need schema validation, tree navigation, large-file search, or IDE integration.

Related Articles