# Defaults Deep

Apply deep default values using lodash _.defaultsDeep

> Canonical page: https://elysiatools.com/en/tools/defaults-deep

- **Category:** Data Processing

- **Keywords:** defaultsDeep, object, lodash, nested, properties

## Overview

Assign default values recursively for undefined properties.

**Highlights:**
- Uses lodash `_.defaultsDeep`
- Applies defaults deeply to nested objects
- Only fills in undefined properties

**Example:**
- Target: `{"a":{"b":1}}`
- Source 1: `{"a":{"b":2,"c":3}}`
- Result: `{"a":{"b":1,"c":3}}`

## Inputs

- **Target Object** (textarea): Enter the target JSON object
- **Source 1** (textarea): First source object
- **Source 2** (textarea): Optional source object
- **Source 3** (textarea): Optional source object

## When to use

- When you need to populate missing configuration settings in a nested JSON object.
- When merging user-provided input with a set of required system defaults.
- When you want to ensure specific keys exist in a data structure while preserving current values.

## How it works

- Input your primary target object containing your current data.
- Provide one or more source objects containing the default values you wish to apply.
- The tool recursively traverses the objects, assigning values from the sources only where the target property is undefined.
- Receive the merged JSON object with all missing nested properties filled in.

## Use cases

- Standardizing API request payloads by injecting missing default parameters.
- Merging user-defined application settings with factory-default configurations.
- Preparing complex data structures for database insertion by ensuring all required fields are present.

## Frequently asked questions

### Does this tool overwrite existing values?

No, it only assigns values to properties that are currently undefined in the target object.

### Can it handle deeply nested objects?

Yes, the tool uses lodash _.defaultsDeep, which performs a recursive merge across all levels of the object hierarchy.

### What happens if a property is null?

Since null is a defined value, the tool will not overwrite it with the default value.

### How many source objects can I provide?

You can provide up to three source objects to merge into your target object.

### Is the output valid JSON?

Yes, the tool returns a clean, valid JSON string representing the merged object.

## Related tools

- [Assign In Object](https://elysiatools.com/en/tools/assign-in-object): Assign own and inherited properties using lodash _.assignIn
- [Flatten Deep Array](https://elysiatools.com/en/tools/flatten-deep-array): Flatten array completely using lodash _.flattenDeep
- [For In Object](https://elysiatools.com/en/tools/for-in-object): Iterate over object properties using lodash _.forIn
- [For Own](https://elysiatools.com/en/tools/for-own): Iterate over own object properties using lodash _.forOwn
- [Invert By](https://elysiatools.com/en/tools/invert-by): Invert keys grouped by values using lodash _.invertBy
- [Invert Object](https://elysiatools.com/en/tools/invert-object): Invert keys and values using lodash _.invert
- [Keys In List](https://elysiatools.com/en/tools/keys-in-list): List own and inherited keys using lodash _.keysIn
- [Keys List](https://elysiatools.com/en/tools/keys-list): List own enumerable keys using lodash _.keys

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [D3.js Data Visualization Samples](https://elysiatools.com/en/samples/d3js-data-visualization): Comprehensive D3.js data visualization examples including charts, maps, animations, and interactive visualizations
- [Rome JavaScript Toolchain Samples](https://elysiatools.com/en/samples/rome): Rome JavaScript toolchain examples including configuration, linting, formatting, bundling, and project management
