Rename Keys Advanced

Renames keys node with extra functionality

Overview

The Rename Keys Advanced node is designed to rename keys (property names) in JSON objects with advanced options. It supports direct key renaming, template-based renaming using a secondary input, and regular expression-based renaming. This node is useful for transforming data structures, especially when integrating systems with differing field naming conventions or when cleaning up data before further processing.

Common scenarios:

  • Mapping API responses to match required input formats.
  • Standardizing property names across different data sources.
  • Bulk-renaming fields using patterns or templates.
  • Selectively keeping only renamed fields for downstream nodes.

Practical examples:

  • Renaming first_name to firstName throughout an object.
  • Using regex to change all keys ending with _id to start with id_.
  • Applying a mapping template from another input to dynamically rename fields.

Properties

Name Type Meaning
Keep Only Renamed Boolean If enabled, only the keys that have been renamed by this node will be kept in the output; all other keys will be removed.
Keys Fixed Collection (list of Key) Specifies explicit mappings of current key names to new key names. Supports deep keys via dot-notation (e.g., level1.level2.key).
  Current Key Name String The existing name of the key to rename. Can use dot-notation for nested properties.
  New Key Name String The new name for the key. Can use dot-notation for nested properties.
Template Fixed Collection (Template) Allows dynamic renaming based on values from a second input. You specify which fields contain the "from" and "to" key names in the template input.
  Current Key Names Field String Name of the field in the template input that contains the current key names to rename.
  New Key Names Field String Name of the field in the template input that contains the new key names.
Regex Fixed Collection (list of Replacement) Enables renaming keys using regular expressions. Multiple replacements can be defined.
  Regular Expression String The regex pattern to match key names.
  Replace With String The replacement string for matched key names. Supports regex capture groups (e.g., $1, $2).
  Options Collection Additional options for regex replacement:
- Case Insensitive: Whether to ignore case.
- Max Depth: How deep into nested objects/arrays to apply the replacement (-1 = unlimited).

Output

  • json: The output is an array of items, each containing a json object where keys have been renamed according to the specified rules:
    • Direct key mappings are applied first.
    • Template-based renaming (if configured) is applied using the second input.
    • Regular expression replacements are then performed.
    • If "Keep Only Renamed" is enabled, only the renamed keys are retained in the output.
  • binary: If the input item contains binary data, it is passed through unchanged.

Example output structure:

[
  {
    "json": {
      "newKey1": "value1",
      "newKey2": "value2"
    }
  }
]

Dependencies

  • Lodash: Used internally for object manipulation (get, set, unset, pick).
  • No external services or API keys are required.
  • No special n8n configuration or environment variables needed.

Troubleshooting

Common issues:

  • No keys are renamed: Ensure that the "Current Key Name" and "New Key Name" fields are both filled and not identical.
  • Nested keys not renamed: Use dot-notation (e.g., parent.child.key) for nested properties.
  • Regex does not match: Double-check your regular expression syntax and options (case sensitivity, depth).
  • Unexpected output when "Keep Only Renamed" is enabled: Only keys that were actually renamed will be present; original keys not renamed will be omitted.

Error messages:

  • None explicitly thrown by the node itself, but misconfiguration may result in missing or incomplete output. Check parameter values if results are not as expected.

Links and References

Discussion