nodes / builtin / datatransformation
Rename Keys
Rename and move keys on an item
Rename fields on your items, one by one or all at once with a pattern, without touching their values.
What it does
Section titled “What it does”Rename Keys changes field names on every incoming item. It has two modes:
- Named keys: you list each rename as From and To. Dots reach nested fields, and a dot path in To moves the value there.
user.firstNametofirst_nameboth renames the field and lifts it to the top level. - Pattern: a regular expression is run on every field name and the matched part is replaced with Replacement.
^data_with an empty replacement strips that prefix from every field.
Values never change, only names and positions. A field that an item does not have is skipped, not treated as an error. Renames are worked out against the original item, so swapping a and b keeps both values.
When to use it
Section titled “When to use it”- Fix one badly named field on a large scraped object without rebuilding the rest.
- Strip or change a prefix on every field, such as
data_orprop_. - Match the field names another service expects before you send data to it.
- To add, change or remove fields, use Edit Fields. To keep only one field, use Pick Field.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Mode | Choice | Rename keys you name, or every key matching a pattern. Options: Named keys, Pattern. Default: Named keys |
| Renames | List of entries | Keys to rename, and what to rename them to. |
| Renames (each entry) › From (required) | Text | Current key. Dots address nested keys. |
| Renames (each entry) › To (required) | Text | New key. Dots move the value to a different place. |
| Pattern | Text | Regular expression matched against each key name. |
| Replacement | Text | What the matched part becomes. Use $1 for groups. Empty removes it. |
| Ignore Case | Toggle | Match the pattern regardless of case. Default: Off |
| Apply To Nested Keys | Toggle | Rewrite keys inside nested objects too. Default: Off |
| On Collision | Choice | What to do when the new name is already taken. Options: Fail, Overwrite, Keep the existing key. Default: Fail |
- Pattern replaces every match inside a name, not just the first. If the result would be an empty name, the field keeps its old name.
- Apply To Nested Keys is for Pattern mode. Off, only top-level names change. On, names at every depth change, including inside lists of objects.
- On Collision decides what happens when the new name already exists: Fail stops the run (the default, so no value is lost by accident), Overwrite replaces the existing value, and Keep the existing key skips that rename.
Outputs
Section titled “Outputs”-
Output
The same items with the new field names. A single incoming item comes out as a single item; a list comes out as a list of the same length.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- HTML Extract returns items with fields
data_title,data_priceanddata_url. - Rename Keys with Mode Pattern, Pattern
^data_and an empty Replacement. The fields becometitle,priceandurl. - A second Rename Keys with Mode Named keys and one rename, From
urlTolink, to match your sheet’s column. - A Google Sheets node (Data, Append Values into Worksheet) adds the items to your sheet.
Common issues
Section titled “Common issues”- “Renaming “…” to “…” would overwrite a value that is already there.“ The new name is already used on the item. Pick another name, or set On Collision to Overwrite or Keep the existing key.
- “Renaming “…” to “…” would overwrite a key of that name produced by another rename.“ In Pattern mode, two names become the same, for example
data_idandidafter strippingdata_. Make the pattern more specific, or change On Collision. - “No renames configured. Add at least one, or switch to the Pattern mode.” Named keys mode needs at least one rename with both From and To filled.
- “The Pattern mode needs a pattern. Add one, for example ^data_ .” Fill Pattern.
- A field did not change. Names are case sensitive: turn on Ignore Case in Pattern mode, or check the spelling in From. For nested fields in Pattern mode, turn on Apply To Nested Keys.
Related nodes
Section titled “Related nodes”- Edit Fields: add, change or remove fields.
- Pick Field: keep a single field.
- Regex: change values, not names, with a pattern.