⊕

JSON Merge Tool

Merge two JSON objects or arrays with multiple strategies

JSON Merge Tool — what it does

Merge two JSON documents with a strategy you choose: a shallow object merge where top-level keys overwrite, a deep merge that recurses into nested objects, or array concatenation. The strategy is the whole decision — shallow replaces a nested object wholesale, deep combines it key by key.

When this tool helps

  • Layering an environment-specific configuration over a base configuration file.
  • Combining two API responses into one document for a single downstream consumer.
  • Appending one array of records onto another before processing them together.

How to use it

  1. Paste the first JSON document.
  2. Paste the second document.
  3. Choose shallow, deep or array concatenation.
  4. Process and copy the merged output.

Accuracy, limits, and good practice

  • Deep merge is what configuration layering needs: a shallow merge replaces an entire nested settings block instead of overriding one field inside it.
  • The second document wins on conflicts, which is what makes the override direction predictable — put the more specific data second.
  • Arrays are replaced rather than merged element by element unless you choose concatenation; there is no reliable way to merge arrays by identity.

Frequently asked questions

What is the difference between shallow and deep?

Shallow overwrites top-level keys entirely. Deep recurses, so nested objects are combined field by field instead of replaced.

Which document takes priority?

The second one. Its values overwrite matching keys from the first.

Can I merge more than two documents?

Merge two, then merge the result with the third, and so on. The order determines the final precedence.

Related tools on this site

Everything above runs inside this page. JSON Merge Tool needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

JSON 合併工具能做什麼

以你選定的策略合併兩份 JSON:淺層合併讓最外層鍵覆蓋、深層合併遞迴進巢狀物件,或直接串接陣列。策略就是全部的決策——淺層會整塊換掉巢狀物件,深層則逐鍵合併。

什麼時候用得上

  • 把環境專屬設定疊在基礎設定檔之上。
  • 把兩份 API 回應併成一份,交給同一個下游使用。
  • 把一組紀錄陣列接到另一組後面再一起處理。

使用步驟

  1. 貼上第一份 JSON 文件。
  2. 貼上第二份文件。
  3. 選擇淺層、深層或陣列串接。
  4. 執行處理並複製合併結果。

精確度、限制與實務建議

  • 設定分層需要的是深層合併:淺層合併會把整個巢狀設定區塊換掉,而不是只覆蓋其中一個欄位。
  • 衝突時以第二份為準,覆蓋方向因此可預測——請把較具體的資料放在第二份。
  • 除非選擇串接,陣列是整個被取代而非逐元素合併;依身份合併陣列本來就沒有可靠做法。

常見問題

淺層與深層差在哪?

淺層直接覆蓋最外層鍵;深層會遞迴,巢狀物件是逐欄位合併而非整個取代。

哪一份優先?

第二份。它的值會覆蓋第一份中相符的鍵。

可以合併超過兩份嗎?

先合併兩份,再把結果與第三份合併,依此類推。順序決定最終優先權。

本站相關工具

以上步驟全部在這個頁面內完成,JSON 合併工具 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。