JSON Merge

Deep merge two or more JSON objects — combine configurations, patch data, and merge API responses.

About JSON Merge

JSON deep merge combines two JSON objects by recursively merging their properties. Unlike a shallow merge (Object.assign), deep merge handles nested objects — so nested configurations are combined rather than replaced. This is essential when merging default settings with user overrides, patching API response data, or combining partial JSON objects from multiple sources.

In a deep merge, JSON B values take precedence over JSON A values when both objects have the same key. For nested objects, the merge recurses into them. For arrays, you can choose to concatenate them or have B replace A.

Common uses include merging application config overrides, combining partial API responses, patching JSON fixture files for testing, and merging Kubernetes manifest overrides with base configurations.

FAQ

What's the difference between deep and shallow merge?
Shallow merge (like JavaScript's Object.assign or spread operator) only merges top-level keys. If both objects have a nested object at the same key, B's nested object completely replaces A's. Deep merge recurses into nested objects, combining their keys instead of replacing them entirely.
Which object takes priority?
JSON B takes priority. When both A and B have the same key with a primitive value (string, number, boolean), B's value is used in the output.