Reference > Nodes

Edit Fields (Set) Node

Reference for the n8n Edit Fields node -- field mapping, expressions, renaming, and data reshaping.

ReferenceIntermediate5 min read

The Edit Fields node (formerly called the Set node) creates, renames, and removes fields on each item passing through the workflow. It is the standard way to reshape data between nodes without writing code.

Modes

Mode Description
Manual Mapping Define fields one at a time using the UI. Each field has a name, type, and value. Best for straightforward field assignments.
JSON Output Provide a raw JSON object that becomes the output item. Best when you want to define the entire output structure at once.

Manual Mapping

In Manual Mapping mode, you add individual field assignments:

Setting Description
Field Name The name of the output field. Supports dot notation for nested fields (e.g., address.city).
Field Type The data type: String, Number, Boolean, Array, Object. Controls how the value is interpreted.
Value A static value or an expression. Expressions can reference input data (e.g., {{ $json.firstName }}).

Add as many fields as needed. Each field produces one key in the output item's JSON.

Expression-Based Assignment

Every value field supports n8n expressions. Use this to compute new values from existing data:

Expression Example Result
{{ $json.firstName + ' ' + $json.lastName }} Concatenates two fields into a full name.
{{ $json.price * $json.quantity }} Multiplies two numeric fields.
{{ $json.email.toLowerCase() }} Normalizes an email to lowercase.
{{ $json.tags.join(', ') }} Converts an array to a comma-separated string.
{{ DateTime.now().toISO() }} Inserts the current timestamp.

Tip

Click the Expression toggle next to a value field to switch between fixed and expression mode. When the toggle is active, the field background turns orange to indicate expression mode.

Key Options

Option Description
Keep Only Set When enabled, the output contains only the fields you define. All other fields from the input are discarded. When disabled (the default), defined fields are merged on top of the existing input data.
Include Other Input Fields Alias for the inverse of Keep Only Set in newer n8n versions. Controls whether unmodified input fields pass through.

Warning: Keep Only Set drops everything else

When Keep Only Set is enabled, any field not explicitly defined in the node is removed. This is intentional for data cleanup, but it can cause downstream nodes to fail if they expect fields that were present in the input. Always verify the output after enabling this option.

Dot Notation for Nested Fields

Use dot notation in the field name to create or modify nested objects:

Field Name Value Output JSON
user.name John { "user": { "name": "John" } }
user.address.city {{ $json.city }} { "user": { "address": { "city": "..." } } }
meta.tags ["a", "b"] (Array type) { "meta": { "tags": ["a", "b"] } }

Note

If the nested parent object does not exist, it is created automatically. If it already exists, only the specified leaf field is updated; other sibling fields are preserved.

Common Patterns

Rename fields to match a downstream API:

HTTP Request --> Edit Fields --> HTTP Request (POST)

An API returns first_name and last_name, but the target API expects firstName and lastName. Map each field to its new name with Keep Only Set enabled to strip the originals.

Field Name Value
firstName {{ $json.first_name }}
lastName {{ $json.last_name }}
email {{ $json.email }}

Add computed fields while keeping originals:

Database --> Edit Fields --> Spreadsheet

Leave Keep Only Set disabled. Add new fields that are derived from the input:

Field Name Value
fullName {{ $json.first + ' ' + $json.last }}
totalPrice {{ $json.unitPrice * $json.qty }}
processedAt {{ DateTime.now().toISO() }}

The output contains all original fields plus the three new ones.

Strip sensitive fields before logging:

Webhook --> Edit Fields (Keep Only Set) --> HTTP Request (log endpoint)

Enable Keep Only Set and define only the fields that are safe to log. Fields like passwords, tokens, or personal data are excluded from the output.

Flatten a nested object:

API Response --> Edit Fields --> Google Sheets

If an API returns nested data like { "user": { "name": "...", "email": "..." } }, flatten it for a spreadsheet:

Field Name Value
userName {{ $json.user.name }}
userEmail {{ $json.user.email }}

Reshape data for a specific schema:

Multiple Sources --> Merge --> Edit Fields --> Database (Insert)

After merging data from multiple sources, use Edit Fields to normalize the combined output into the schema expected by the destination database.

Tips and Gotchas

  • Expressions vs static values. If a value field shows the raw text {{ $json.name }} in the output instead of the resolved value, the expression toggle is not active. Click the toggle to switch to expression mode.
  • Field order does not matter. The order of fields in the Edit Fields UI does not affect the output JSON. JSON objects are unordered by nature.
  • Empty values are included. If an expression resolves to null or undefined, the field is still included in the output with that value. To omit a field conditionally, use a Code node instead.
  • Array and Object types. When the field type is set to Array or Object, the value must be valid JSON. A common mistake is entering an unquoted string or missing brackets.
  • Chaining Edit Fields nodes. It is fine to use multiple Edit Fields nodes in sequence. The first one can add fields, and the second can use Keep Only Set to select the final shape. This is often clearer than doing everything in one node.
  • Performance. The Edit Fields node is lightweight and adds negligible overhead. Prefer it over a Code node for simple field mapping tasks.

Common Errors

Output shows the literal text {{ $json.fieldName }} instead of the resolved value. The expression toggle is not active on the value field. Click the = icon next to the field to switch to expression mode. When expression mode is active, the field background turns orange.

Downstream nodes report missing fields after enabling "Keep Only Set." Keep Only Set discards all input fields that are not explicitly defined in the node. If downstream nodes depend on fields from the input, either disable Keep Only Set or add those fields explicitly to the node's field list.

Nested field assignment produces [object Object] instead of the expected value. When setting a field type to String but assigning a nested object expression, n8n converts the object to its string representation. Change the field type to Object or Array as appropriate, or use dot notation to access a specific leaf value (e.g., {{ $json.user.name }} instead of {{ $json.user }}).

See Also

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.