Merge JSON Files - Combine Several JSON Files into One

Upload or drag in several JSON files, or paste JSON text, and combine them in one of three ways: as an array, with a deep merge or with a shallow merge. A live preview shows the merged JSON. You can sort the keys, copy the result or download it as a .json file. If a file is not valid JSON, the tool tells you which file it is and where the problem is. Free, no signup, and it runs in your browser.

The tool reads standard JSON only. It merges in the order of the list, and a later file overrides an earlier one. JSON files often hold settings, tokens or keys, so use test or cleaned copies and do not put real secrets into any online tool.

Merge JSON Files

Merge Multiple JSON Files into One Instantly • 100% Free • No Sign Up • For Developers

✅ 100% Client-Side ✅ Deep + Shallow + Array Merge ✅ No Server ● Ready - Upload JSON files or paste JSON text
Current Mode: Merge as Array
Select Deep Merge for nested objects, Shallow Merge to replace nested objects.
📁 Upload JSON Files
📄
Drag & Drop JSON Files Here
or Click to Browse - Multiple files allowed (Max 10 files)
Click Browse Files to select .json files from your computer
— OR —
⚠️ Important: After pasting JSON in the textbox below, you MUST click Add as File, otherwise Merge will NOT include this text. If you click Merge JSON Now directly, pasted text will be auto-added.
Tip: Paste one JSON, click Add as File, then paste next JSON and click Add as File again. Repeat for all files.
🔀 Merge Mode
⚙️ Merge Options
If checked, merged JSON keys will be sorted alphabetically.
👁️ Live Preview - Merged JSON
No files yet

Merged result appears here instantly. Green = Valid, Red = Error.

// Your merged JSON will appear here...

// 1. Upload multiple .json files OR paste JSON and click Add as File
// 2. Select Merge Mode - Array / Deep / Shallow
// 3. Click Merge JSON Now
// 4. Copy or Download the result
Keys: 0 • Size: 0 B • Mode: Array Lines: 0
💡 How to Use - Examples
Merge as Array
File 1: {"a":1}
File 2: {"b":2}
Result: [{"a":1},{"b":2}]
Deep Merge
File 1: {"user":{"name":"John"}}
File 2: {"user":{"age":25}}
Result: {"user":{"name":"John","age":25}}
Shallow Merge
File 1: {"user":{"name":"John"}}
File 2: {"user":{"age":25}}
Result: {"user":{"age":25}} - Nested replaced
Steps for Paste Method: 1. Paste first JSON in textbox - Click Add as File   2. Paste second JSON in textbox - Click Add as File again   3. Select Deep Merge   4. Click Merge JSON Now
Frequently Asked Questions

Q: I pasted JSON in the textbox and clicked Merge, but my pasted JSON did not merge. Why?
A: Because pasted text is NOT auto-added until you click Add as File. Steps: Paste JSON in textbox - Click Add as File - Paste next JSON - Click Add as File again - Then click Merge JSON Now. If you forget to click Add as File, Merge will auto-add the pasted text once, but for multiple pastes you must click Add as File every time.

Q: Do I need to click Add as File after pasting JSON?
A: Yes. Pasting alone only fills the textbox, it does NOT add it to the file list. You must click Add as File to add it to Uploaded Files list. Check the Uploaded Files count - it should increase by 1 after every Add as File click.

Q: What is the difference between Deep Merge and Shallow Merge?
A: Deep Merge merges nested objects key by key. Example: File 1 {"user":{"name":"John"}} + File 2 {"user":{"age":25}} = {"user":{"name":"John","age":25}}. Shallow Merge replaces nested objects fully. Same example in Shallow = {"user":{"age":25}} - name is lost.

Q: Why is my Deep Merge output showing only the second file?
A: Most common reason is you forgot to click Add as File for the first file, or you selected Shallow Merge by mistake. Check Current Mode badge on top - it must show Deep Merge. Also check Uploaded Files count - it must show 2 files before merging.

Q: Is my JSON uploaded to a server?
A: No. 100% browser processing. Your files never leave your browser.

Q: What if a file has invalid JSON?
A: Tool shows exact file name and line number, e.g. File 2 has invalid JSON at line 3. Fix that file and try again.

Share on WhatsApp Back to Home Page

What Does It Mean to Merge JSON Files?

JSON is the most common format for settings, translations, API responses and exported data, and sooner or later the data you need is spread over several files. Merging means producing one JSON document from many. How that is done depends on what the files hold. If they are lists of records, you probably want one long list. If they are layers of settings, you probably want one object in which later layers override earlier ones. This tool offers three modes for these cases, so that you do not have to write a script for each.

Everything runs in your browser. The files are read on your device, merged there and shown to you. They are not sent anywhere.

How to Merge JSON Files

  1. Add your files. Click the drop area and choose several files, drag them onto it, or paste JSON text and add it as another input.
  2. Check the order. The inputs are merged in the order of the list. Move a file up or down if a base file should come first.
  3. Choose a mode. Merge as Array, Deep Merge or Shallow Merge. A short note under the choice explains what it does.
  4. Tick Sort Keys if you want the keys in alphabetical order.
  5. Read the preview. The merged JSON appears and updates when you change anything.
  6. Copy or download. Click Copy JSON, or Download as .json to save the result as a file.

If a file is not valid JSON, the tool shows an error that names the file and the line, and no merged result is shown until every file is valid.

What You See on the Page

ItemMeaning
Drop area and paste boxWhere you add JSON files or JSON text
List of inputsThe files in the order in which they are merged, each with a Remove button and a way to change its place
Merge modeMerge as Array, Deep Merge or Shallow Merge
Sort KeysSorts the keys of all objects in the result alphabetically
Live previewThe merged JSON, formatted so that it is easy to read
Copy JSONCopies the merged JSON
Download as .jsonSaves the merged JSON as a file
Error messageNames an invalid file and shows the line and column of the problem

The Three Merge Modes at a Glance

ModeResultFiles must beSame key in two filesGood for
Merge as ArrayOne arrayAnything: objects, arrays or single valuesNot applicable, every item is keptCombining lists of records, pages of an API response, test data
Shallow MergeOne objectObjects at the top levelThe later file replaces the whole value of the keySimple settings files with flat keys, quick overrides
Deep MergeOne objectObjects at the top levelNested objects are merged key by key, and other values are overwritten by the later fileLayered settings, translation files, base file plus overrides

A Worked Example

These two small files use made-up values. File 1 is a base, and File 2 holds overrides.

File 1 (base.json):

{
  "name": "demo-app",
  "settings": {
    "theme": "dark",
    "language": "en"
  },
  "tags": ["web", "tools"]
}

File 2 (overrides.json):

{
  "settings": {
    "theme": "light",
    "debug": false
  },
  "tags": ["production"],
  "version": 2
}

Result with Shallow Merge

Only the top-level keys are combined. The key settings exists in both files, so File 2 replaces the whole value, and language from File 1 is lost. The same happens to tags.

{
  "name": "demo-app",
  "settings": {
    "theme": "light",
    "debug": false
  },
  "tags": [
    "production"
  ],
  "version": 2
}

Result with Deep Merge

The two settings objects are merged key by key. theme clashes, so File 2 wins, and language and debug are both kept. The arrays under tags are not joined: the later array replaces the earlier one.

{
  "name": "demo-app",
  "settings": {
    "theme": "light",
    "language": "en",
    "debug": false
  },
  "tags": [
    "production"
  ],
  "version": 2
}

Result with Merge as Array

Each file is an object, so each one becomes an item of the result.

[
  {
    "name": "demo-app",
    "settings": {
      "theme": "dark",
      "language": "en"
    },
    "tags": [
      "web",
      "tools"
    ]
  },
  {
    "settings": {
      "theme": "light",
      "debug": false
    },
    "tags": [
      "production"
    ],
    "version": 2
  }
]

The same Deep Merge with Sort Keys

{
  "name": "demo-app",
  "settings": {
    "debug": false,
    "language": "en",
    "theme": "light"
  },
  "tags": [
    "production"
  ],
  "version": 2
}

Merge as Array in Detail

This mode collects everything into one array, in the order of the list. What happens to each file depends on what it contains.

A file containsWhat is added to the result
An arrayIts items, one by one. The array itself is not nested
An objectThe object, as one item
A single value (a string, a number, true, false or null)That value, as one item

Example: File A is [{"id": 1}, {"id": 2}] and File B is [{"id": 3}]. The result is one flat array with three items.

[
  {
    "id": 1
  },
  {
    "id": 2
  },
  {
    "id": 3
  }
]

This is the right mode for pages of an API response saved as separate files, for exports from several sources and for test data. It does not remove duplicates and does not match items by an id. Every item is kept.

Shallow Merge in Detail

Shallow Merge looks only at the keys at the top level. For each key, the value from the last file that has it is used. It does not look inside the values. In JavaScript, it works like { ...fileA, ...fileB } or Object.assign.

  • Every file must have an object at the top level.
  • If two files have the same top-level key, the later file's whole value replaces the earlier one, even when both values are objects.
  • Keys that appear in only one file are kept.
  • It is fast, predictable and easy to explain, and it is a good choice when your files are flat or when you really want a whole section replaced.

Deep Merge in Detail

Deep Merge goes inside nested objects, so a later file can override one setting without wiping out its neighbours. The rules for each case are fixed, and the table lists all of them.

Case (same key in an earlier and a later file)Result
Both values are objectsThey are merged key by key, with these same rules applied inside
Both values are arraysThe later array replaces the earlier one. They are not joined
One value is an object and the other is not (for example a string or an array)The later value replaces the earlier one
Both values are single values (strings, numbers, true, false)The later value replaces the earlier one
The later value is nullnull replaces the earlier value, and the key stays in the result with the value null
The key exists in only one fileIt is kept as it is

Deep Merge needs objects at the top level of every file. It does not report conflicts, so if the order of your files is important, read the preview.

Different tools, different rules for arrays

The treatment of arrays is where deep merge tools differ most, so a result from this tool may not match a result from a library or a command.

ApproachWhat happens to two arrays with the same key
This tool, Deep MergeThe later array replaces the earlier one
jq recursive merge (*)The later array replaces the earlier one
lodash mergeThe arrays are merged by position: item 0 with item 0, item 1 with item 1, and so on
A custom merge that joins arraysThe items of the later array are added after the earlier ones

If you expect arrays to be joined or merged by position and this tool replaces them, that is the reason for the difference.

Which Mode Should You Choose?

Your situationMode
Several files that are all lists of records, and you want one long listMerge as Array
Pages of an API response saved as separate filesMerge as Array
A base settings file and a file with a few overrides, with nested sectionsDeep Merge
Translation files where a second file adds or fixes some keysDeep Merge
Flat files, or you want a whole section replacedShallow Merge
You want to keep every file as a separate item in one arrayMerge as Array, with files that hold objects
You need to join arrays that sit inside objects, or match records by an idA script. The tool does not do this

The Order of the Files Matters

Files are merged in the order of the list. In Shallow Merge and Deep Merge, a later file overrides an earlier one, so the order decides the result.

  • Put the base file first and the overrides after it.
  • If you add several override files, the last one has the final say.
  • In Merge as Array, the order of the files is the order of the items in the result.
  • Use the buttons to move a file up or down, and watch the preview change.

Sort Keys

When Sort Keys is ticked, the keys of every object in the result are sorted alphabetically, including objects inside other objects. This gives the same output whatever order the keys had in your files, which is useful for clean version control differences and for comparing two results.

  • The order of items in arrays is not changed, because the order of an array carries meaning.
  • Sorting follows character codes, so capital letters come before lowercase letters: Zebra comes before apple.
  • Keys that are whole numbers, such as 1 and 20, are always listed first in ascending order, because that is how JavaScript orders object keys.
  • Without Sort Keys, keys keep the order in which they first appeared.

Invalid JSON and Error Messages

Before merging, the tool checks every file. If a file is not valid JSON, the error names the file and shows the line and column where the parser found the problem, for example: File 2 (settings.json) has invalid JSON at line 7, column 3. Line numbers start at 1. If several files are invalid, all of them are listed, and no merged result is shown until they are fixed.

The most common mistakes in JSON files

What you haveProblemFix
{"a": 1,}A comma after the last item (a trailing comma)Remove the last comma
{'a': 1}Single quotes. JSON needs double quotesUse double quotes for keys and strings
{a: 1}A key without quotesPut the key in double quotes
{"a": 1 "b": 2}A missing comma between itemsAdd a comma
// a note or /* a note */Comments are not part of JSONRemove the comments
{"a": undefined} or NaNThese values do not exist in JSONUse null or leave the key out
One JSON value on each lineJSON Lines format, which is not one JSON documentPut the values in an array first
An empty fileThere is nothing to readRemove the file or add content

Why the error can point to the wrong line

A parser can only tell that something is wrong when it reads a character that does not fit. A missing comma between two items is noticed at the start of the next key, which is often on the next line. When an error looks wrong, read the reported line and the line above it.

What Happens to Your Data

The tool reads each file as standard JSON, merges the values and writes the result again. This is simple, but it has a few effects that are worth knowing, especially for developers who compare files line by line.

EffectExample
The formatting is replaced by standard formatting with an indent of two spacesYour original line breaks and spacing are not kept
Numbers are read as floating-point values and written in their shortest form1.0 becomes 1, and 1e3 becomes 1000
Whole numbers above 9007199254740991 can lose precision9007199254740993 becomes 9007199254740992. Keep long IDs as strings
A key that appears twice in one file keeps only the last valueThe first value is dropped without a message
Escape sequences can be written as the real character\u00e9 becomes the letter é, which means the same thing
Keys that are whole numbers move to the front{"b": 1, "2": 2} is written with 2 first

If you need a byte-for-byte copy of your original files, or exact big numbers, merge with a script that keeps the original text of the numbers.

From the Command Line

For large files or for automation, a command-line tool or a short script is a better fit. These are common ways to do the same three merges, so that you can compare results.

# Merge as Array, with arrays joined into one flat array (jq)
jq -s 'add' a.json b.json

# Shallow Merge: later file wins for the same top-level key (jq)
jq -s 'add' a.json b.json

# Deep Merge: nested objects merged, later file wins, arrays replaced (jq)
jq -s '.[0] * .[1]' a.json b.json

# Shallow Merge in JavaScript
const merged = { ...a, ...b };

With jq -s 'add', objects are combined with the later one winning, and arrays are joined, so the result depends on what the files hold. The first and the second line are the same command, because add does the right thing for each type. Check the documentation of the tool that you use for the exact rules.

What Can You Use It For?

UseModeNote
Combining translation files, such as a base language file and a file with fixesDeep MergeNested keys are kept and only the clashing keys are overwritten
Layering settings: a base file plus a file for one environmentDeep MergeArrays in the override file replace the base arrays. They do not add to them
Joining pages of an API response that you saved as separate filesMerge as ArrayEach file is an array, and the result is one flat array
Combining test data or mock data from several filesMerge as ArrayEvery item is kept, and duplicates are not removed
Combining exports from several systemsMerge as ArrayCheck that the records have the same fields
Adding a few top-level keys to a flat fileShallow MergeSimple and predictable

Take care with files that tools read in a strict way, such as package.json or a compiler configuration. A merged result can be valid JSON and still be wrong for the tool, for example when a list of dependencies or a list of paths is replaced and not extended. Always test a merged file in the place where you will use it.

Tips for Reliable Merges

  • Start with valid files. Open each file in a JSON formatter or an editor first if you are not sure about it.
  • Set the order before you read the result. It is the most common reason for a surprising merge.
  • Prefer Deep Merge for layered settings and Shallow Merge when you want whole sections replaced.
  • Remember that arrays are replaced in Deep Merge. If a list must grow, put the full list in the later file.
  • Use Sort Keys when you want to compare two results or keep clean diffs in version control.
  • Keep long IDs as strings in your data, so that no tool can change them.
  • Check the result with a diff. The Diff Checker on this website can compare the merged file with your base file, so that you see exactly what changed.
  • Keep your originals. Download the merged file under a new name and leave the source files untouched.
  • Use cleaned copies of files that hold secrets.

Common Mistakes

  • Putting the files in the wrong order: The later file wins, so an override placed first is overridden by the base.
  • Using Shallow Merge on nested settings: A whole section is replaced and the keys that are only in the earlier file are lost.
  • Expecting arrays to be joined in Deep Merge: They are replaced. Use Merge as Array for top-level arrays.
  • Using Deep or Shallow Merge on files that hold arrays: These modes need objects at the top level.
  • Trusting big numbers: Whole numbers above 9007199254740991 can change.
  • Pasting JSON with comments or trailing commas: It is not valid JSON.
  • Merging files that hold secrets in an online tool: Use cleaned or test copies.
  • Not testing the merged file: Valid JSON is not always correct for the tool that reads it.

Good to Know

  • The tool reads standard JSON only. It does not read comments, trailing commas, single quotes, unquoted keys or JSON Lines.
  • It does not check your data against a schema and does not report which keys clashed.
  • It does not remove duplicates and does not match records by an id.
  • The result is written with an indent of two spaces. Your original formatting is not kept.
  • There are limits on the size and the number of files, and the tool tells you when you go over them.
  • The preview shows plain text. Any HTML that appears inside your JSON strings is shown as text and is not run.

Privacy

  • Your files are read and merged in your browser, on your own device, and they are not sent to our server.
  • We do not save your files or the merged result. They disappear when you close or reload the page, so copy or download what you need.
  • JSON files often contain settings, tokens, passwords or keys. Use test or cleaned copies, and do not put real secrets into any online tool.
  • On a shared or public computer, close the page and delete the downloaded files when you finish.

Frequently Asked Questions

How do I merge JSON files?

Add two or more JSON files by uploading them, dragging them onto the page or pasting text. Choose Merge as Array, Deep Merge or Shallow Merge, and tick Sort Keys if you want the keys in alphabetical order. The merged JSON appears in the live preview. Click Copy JSON or Download as .json to take the result.

What is the difference between Merge as Array, Deep Merge and Shallow Merge?

Merge as Array puts the contents of all the files into one array. Shallow Merge combines the top-level keys of the files into one object, and when two files have the same top-level key, the whole value from the later file replaces the earlier one. Deep Merge goes inside nested objects and combines them key by key, so only the values that really clash are overwritten.

What happens when two files contain the same key?

The file that comes later in the list wins. In Shallow Merge it replaces the whole value of that key. In Deep Merge, if both values are objects they are merged key by key, and in all other cases the later value replaces the earlier one. Nothing is reported as a conflict, so check the result when the order matters.

How does Deep Merge treat arrays?

An array in a later file replaces the array with the same key in an earlier file. The two arrays are not joined and not merged item by item. Some libraries behave differently, for example lodash merge combines arrays by position, so results from other tools can differ. To join the contents of several top-level arrays, use Merge as Array. This tool cannot join arrays that sit inside objects.

Does the order of the files matter?

Yes. Files are merged in the order of the list. In Shallow Merge and Deep Merge a later file overrides an earlier one, so put a base file first and its overrides after it. In Merge as Array, the order decides the order of the items in the result.

What does Merge as Array do with files that already contain arrays?

The items of an array file are added to the result one by one, so two files that each hold an array of records give one flat array with all the records. A file that holds an object or a single value is added as one item. Arrays are not nested inside the result array.

Can I use Deep Merge or Shallow Merge on files that start with an array?

No. These two modes combine objects, so every file must have an object at the top level. If a file holds an array or a single value, the tool shows a message that names that file. Use Merge as Array for such files.

What does Sort Keys do?

It sorts the keys of every object in the result in alphabetical order, including objects inside other objects, so that the output is the same whatever order the keys had in your files. The order of items in arrays is not changed. Sorting follows character codes, so capital letters come before lowercase letters.

How does the tool report invalid JSON?

It names the file, for example File 2, and shows the line and column where the parser found the problem. Fix that file and add it again. If several files are invalid, each one is listed. No merged result is shown until all the files are valid.

Why does the error point to a line after the real mistake?

A parser can only tell that something is wrong when it reads a character that does not fit. A missing comma, for example, is noticed at the start of the next key, which is often on the next line. Look at the reported line and at the line above it.

What are the most common causes of invalid JSON?

Trailing commas after the last item, single quotes instead of double quotes, keys without quotes, missing commas between items, comments, and values such as undefined or NaN that JSON does not have. A file in JSON Lines format, where each line is a separate JSON value, is also not one valid JSON document.

Can it merge JSON with comments, JSON5 or JSON Lines files?

No. The tool reads standard JSON only. Comments, trailing commas, single quotes and unquoted keys are not accepted, and files in JSON Lines format, with one JSON value on each line, are not supported. Convert or clean such files first.

Are large numbers and number formats kept exactly?

Not always. The tool reads numbers the way a browser does, as floating-point values, so whole numbers above 9007199254740991 can lose precision, for example 9007199254740993 becomes 9007199254740992, and numbers are written in their shortest form, so 1.0 becomes 1. If exact big numbers matter, such as long IDs, keep them as strings in your source data.

Can it merge arrays of objects by an id field?

No. It joins arrays one after the other and does not match items by an id or any other field. Merging records by a key needs a rule for conflicts, so use a script for that.

Will the key order and the formatting of my files be kept?

No. The result is written again with standard formatting and an indent of two spaces. Keys keep the order in which they first appeared, except that keys that are whole numbers are listed first in ascending order, which is how JavaScript orders them. Tick Sort Keys for a fixed alphabetical order.

Are my files uploaded to a server?

No. The files are read and merged in your browser, on your own device, and they are not sent to our server. We do not save them. JSON files often hold settings, tokens or keys, so use test or cleaned copies when you can and do not put real secrets into any online tool.

Is there a limit on the size or the number of files?

Yes. Very large files and very many files can use more memory than a browser has, so the tool has limits and tells you when you go over them. For large data sets, merge with a script or a command-line tool such as jq.

Does it work on a phone?

Yes, the page is designed for phone screens. Choosing files and downloading work differently on different phones, and on some of them the file opens in a new tab, from where you save it. Large files are better merged on a computer.

Is this tool free?

Yes. The tool is free and needs no signup.