Steps
A green run that renamed nothing: the Current Key must match exactly
When Current Key does not match, Rename Keys does nothing and still shows a green run. In our runs
first nameon a field calledFirst Namedid nothing (case counts),emailwith a trailing space did nothing, and an empty New Key left the field as it was. Accented keys work if typed exactly:Prénomtoprenomworked. Copy the key from the input data instead of typing it.CSV with a BOM: the first key has an invisible character
A CSV saved with a BOM gives the first column a key that starts with an invisible
\ufeffcharacter. Current Keynameon that key did nothing, with a green run. Fix it where the file is read: see the BOM part of n8n Extract From File (CSV) not working. To see the real key names, you can put{{ JSON.stringify(Object.keys($json)) }}in an Edit Fields value (we did not run this check).Dots in a key are paths, not plain text
Current Key
user.nameon{"user":{"name":"Ann","age":3}}moved the value out of the object: the result was{"user":{"age":3},"name":"Ann"}. A dot in New Key does the opposite:emailtocontact.emailgave{"contact":{"email":"a@x.io"}}. A flat key that really is calleduser.namewas renamed too. Array paths work the same way:items[0].skutoskumoved the value out and left"items":[{}], an empty object, behind.Renaming to a key that already exists overwrites it
Renaming
emailtoidon an item that already hadid: 1gave{"First Name":"Ann","id":"a@x.io"}. The old id was gone and there was no warning. Check that the New Key is not already used, or rename the existing field first in a separate node.Swapping two keys loses a value, and pairs do not chain
Two pairs
atobandbtoaon{"a":1,"b":2}gave{"a":2}: the value 1 was lost, with a green run. Two pairsatobandbtocon{"a":1}gave{"b":1}: the second pair did not see the key the first pair had just created. Each pair reads the keys of the input item, not the result of the pair before it. So a swap through a temporary key will probably also fail inside one node; use two Rename Keys nodes or an Edit Fields node instead (we did not run either fix).The renamed key moves to the end of the item
Renamed keys are added at the end.
{"a":1,"b":2,"c":3}withbrenamed tozgave{"a":1,"c":3,"z":2}, andFirst Namerenamed tofirst_nameended up afteremailandid. Values do not change, but column order in a CSV, Google Sheets or table built from these items will. If order matters, set the fields in the order you want with Edit Fields.Regex replaces only the first match in each key
The Regex option (Add option, Regex) is not global. Search
(a space) with Replace With_turnedZip Code HereintoZip_Code Here, and\s+gave the same result.[A-Z]toxturnedFirstNameintoxirstName. To replace every space, add the same replacement once per space, or rename the keys in a Code node withreplaceAll(we did not run the Code node version). Other regex results: Case Insensitive made^name$matchNAME; capture groups work,^(\w+) (\w+)$to$2_$1gaveName_First; nested keys were renamed too (user.namebecameuser.nm), with the default depth and with depth -1. An invalid pattern such as(unclosedfails the node withInvalid regular expression: /(unclosed/: Unterminated group.Key pairs run before the regex, and expressions work
With both a key pair and a regex, the pair ran first:
First Nametofirstby the pair, thenLast NametoLast_Nameby the regex. Expressions work in Current Key:{{ 'email' }}renamed email, and{{ Object.keys($json)[0] }}renamed the first key of each item. Items without the key pass through unchanged, a key whose value isnullis still renamed, and an empty item{}passes through as{}. Google Sheets style headers such asEmail AddressandPhone Numberrenamed fine, androw_numberwas kept.
What we ran
On 24 October 2026 we ran 28 executions of the Rename Keys node v1 on self-hosted n8n 2.43.7 with n8n execute: a Manual Trigger, a Code node with test items, the Rename Keys node and a Code node that recorded the output. 27 runs succeeded and 1 failed. Every value below is copied from those runs.
| Setup | Result |
|---|---|
First Name to first_name | Renamed, moved to the end: {"email","id","first_name"} |
Current Key first name (wrong case) | Green run, nothing renamed |
Current Key email (trailing space) | Green run, nothing renamed |
user.name to name on nested user | {"user":{"age":3},"name":"Ann"} |
user.name to name on a flat key "user.name" | {"name":"Ann"} |
email to id, id already exists | Old id overwritten: {"First Name":"Ann","id":"a@x.io"} |
Swap: a to b, b to a on {"a":1,"b":2} | Green run, value lost: {"a":2} |
Chain: a to b, b to c on {"a":1} | {"b":1}, second pair skipped |
email to contact.email | {"contact":{"email":"a@x.io"}} |
| Empty New Key | Green run, nothing renamed |
Current Key expression {{ 'email' }} | Renamed |
Current Key expression {{ Object.keys($json)[0] }} | First key renamed |
Regex space to _ | First_Name, Last_Name, Zip_Code Here |
Regex \s+ to _ | Zip_Code Here (first match only) |
Regex ^name$, Case Insensitive, on NAME | full_name |
Regex name to nm, default depth | Top-level and nested keys renamed |
| Same, depth -1 | Same result |
Regex ^(\w+) (\w+)$ to $2_$1 | Name_First |
Regex (unclosed | Error: Invalid regular expression: /(unclosed/: Unterminated group |
Regex [A-Z] to x on FirstName | xirstName (first match only) |
3 items, one without the key, one with null | Missing key unchanged, null renamed |
items[0].sku to sku | {"items":[{}],"sku":"A1"} |
Email Address, Phone Number plus row_number | Renamed, row_number kept (now first) |
b to z on {"a":1,"b":2,"c":3} | {"a":1,"c":3,"z":2} |
Prénom to prenom | Renamed |
name on a key with a BOM (\ufeffname) | Green run, nothing renamed |
Key pair plus regex space to _ | Pair first: first, then Last_Name |
Empty item {} | {} |
Quick checklist
- Nothing renamed? Compare Current Key with the input key letter by letter: case, spaces, a BOM on the first CSV column.
- Value moved into or out of an object? A dot in a key is a path.
- A field disappeared? The New Key already existed, or two pairs swapped keys.
- Only the first space replaced? Regex replaces the first match per key.
- Node fails with "Invalid regular expression"? Fix the pattern, for example close the bracket.
- Columns in a new order? Renamed keys go to the end.
Good to know
- The BOM on the first CSV key often comes from n8n itself: Convert to File wrote one at the start of every CSV in our runs. See n8n Convert to File not working.
- Setting fields in a fixed order, or renaming while you change types: n8n Edit Fields (Set) node. CSV keys with
\ufeffor the wrong delimiter: n8n Extract From File (CSV). - Renaming keys inside an array of objects? Turn the array into items first: n8n Split Out, Aggregate and Summarize. Sorting by the renamed field: n8n Sort node.
- Every error message we reproduced is in the n8n error message index.
What we didn't test
- The editor UI itself (we ran workflows from JSON, so labels may differ slightly), n8n Cloud, and other versions of the node.
- The fixes marked "we did not run": two Rename Keys nodes or Edit Fields for a swap, a Code node with
replaceAll, and theObject.keyscheck in Edit Fields.
Start from a working agent
FAQ
Why does the n8n Rename Keys node not rename my field?
The Current Key does not match the input key exactly. In our runs a case difference, a trailing space, a CSV BOM on the first key and an empty New Key all left the field unchanged with a green run.
How do I rename a nested field with n8n Rename Keys?
Use dot notation. user.name as Current Key moves the value out of user to the top level, and a dot in New Key, such as contact.email, creates a nested object.
Why did a field disappear after Rename Keys?
Renaming to a key that already exists overwrites it without a warning, and swapping two keys in one node lost one value in our runs.
How do I replace all spaces in key names in n8n?
The Regex option in Rename Keys replaces only the first match per key, even with \s+. Add the replacement once per space, or use a Code node with replaceAll (we did not run the Code node version).
What does "Invalid regular expression: Unterminated group" mean in n8n Rename Keys?
The regex pattern has an opening bracket without a closing one, such as (unclosed. Close the group or escape the bracket as \(.
Why did Rename Keys change the order of my columns?
Renamed keys are added at the end of each item. Values stay the same; use Edit Fields if you need a fixed column order.
Related guides
- n8n Edit Fields (Set) node not working: dropped fields, type errors and invalid JSON, 29 runs
- n8n Convert to File not working: empty CSV, lost fields and broken base64, 38 runs
- n8n Extract From File (CSV) not working: delimiter, BOM, encoding and errors, 32 runs
- n8n Google Sheets node not working: Bad request, invalid_grant, private key fixes
- n8n “Connection lost” behind a reverse proxy? 15 Nginx setups tested
New guides
- GitHub release notifications in Slack (any public repo, stable releases only)
- Send RSS feeds to Slack with a keyword filter (free, incoming webhook)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- n8n Google Sheets Trigger not working: not firing, activation errors and fixes