Merge & Combine JSON Files Online

Trying to manually combine a bunch of JSON files is a nightmare, especially when fields overlap or nesting gets deep. We built this tool to make merging JSON datasets fast and simple. Just drag your files in, and we'll join them into one clean, valid file right in your browser. No data is ever sent to a server.

Want to test drive the tool?

Before & After

Deep merge in action

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

Four simple steps

1

Drop Your Files

Drag and drop .json files or click to browse. Validated on upload.

2

Auto Validation

Syntax errors and mismatched brackets detected automatically.

3

Choose Strategy

Select merge behavior: overwrite, concat, or deep merge.

4

Download Result

Get formatted JSON with proper indentation instantly.

Programmatic Merge

Python, Node.js, jq

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

Use Cases

Real-world scenarios

API Response Aggregation

Combine paginated API responses or multi-endpoint data into a single JSON file for dashboards, analytics, or database imports.

Config File Layering

Deep merge base, dev, staging, and production config files. Later files override earlier values while preserving shared defaults.

i18n Translation Consolidation

Merge translation JSON files from multiple translators or regions into one complete locale file without losing any keys.

Test Data Assembly

Combine fixture files, mock API responses, and seed data into unified test datasets for your CI/CD pipeline.

FAQ

Common questions

Related Articles

Related Articles

Complete Guide

In-depth walkthrough

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].

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. If you need different behavior, use the Python code example above to customize the merge logic.

Merging JSON files with conflicting keys

When both files have the same key with different values, the last file wins by default in a shallow merge. 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.

If you need custom conflict resolution (keep the higher value, merge arrays at that key, or prompt for manual selection), you'll need to do it in code. Check the Python example above for a starting point.

How the tool handles invalid JSON

The tool validates both files before merging and shows you exactly which file and roughly where the error is. You'll see a message like "Error in file2.json at line 12" with the problematic content.

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.