# Assign Object

Assign source properties to a target object using lodash _.assign

> Canonical page: https://elysiatools.com/en/tools/assign-object

- **Category:** Data Processing

- **Keywords:** assign, object, lodash, merge, properties

## Overview

Assign own enumerable properties from sources to the target object.

**Highlights:**
- Uses lodash `_.assign`
- Later sources override earlier ones
- Returns the merged object

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

## 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 update a base configuration object with new values from multiple sources.
- When you want to consolidate several JSON objects into a single, unified data structure.
- When you need to apply property overrides programmatically without manually editing complex JSON files.

## How it works

- Input your base JSON structure into the Target Object field.
- Add your source objects into the provided Source fields.
- The tool processes the inputs using lodash _.assign, where subsequent sources take precedence over previous ones.
- Retrieve the final merged JSON object as the output.

## Use cases

- Merging default application settings with user-specific overrides.
- Combining partial data fragments from different API responses into a single record.
- Updating state objects in a predictable, sequential manner.

## Frequently asked questions

### What happens if two sources have the same key?

The value from the source that appears later in the input sequence will overwrite the value from the earlier source.

### Does this tool perform a deep merge?

No, this tool uses lodash _.assign, which performs a shallow assignment of own enumerable properties.

### What format should the input objects be in?

Inputs must be valid JSON objects enclosed in curly braces.

### Are non-enumerable properties included?

No, only the source object's own enumerable properties are assigned to the target.

### Can I use this to merge more than two objects?

Yes, you can provide a target object and up to three additional source objects to be merged in sequence.

## Related tools

- [Defaults Object](https://elysiatools.com/en/tools/defaults-object): Apply default values to an object using lodash _.defaults
- [From Pairs](https://elysiatools.com/en/tools/from-pairs): Convert array of key-value pairs to object using lodash _.fromPairs
- [Fill Array](https://elysiatools.com/en/tools/fill-array): Fill array with value from start to end index using lodash _.fill
- [Flatten Depth Array](https://elysiatools.com/en/tools/flatten-depth-array): Flatten array to specified depth using lodash _.flattenDepth
- [Sorted Unique](https://elysiatools.com/en/tools/sorted-unique): Remove duplicates from a sorted array using lodash _.sortedUniq
- [Sorted Unique By](https://elysiatools.com/en/tools/sorted-unique-by): Remove duplicates from a sorted array using lodash _.sortedUniqBy
- [Uniq By](https://elysiatools.com/en/tools/uniq-by): Remove duplicates from an array using lodash _.uniqBy with a property path
- [Zip Object](https://elysiatools.com/en/tools/zip-object): Create an object from keys and values using lodash _.zipObject

## 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
