↻

JSON Key Renamer

Rename matching object keys recursively throughout JSON data

JSON Key Renamer — what it does

Rename every occurrence of a key throughout a JSON document, recursing through nested objects and arrays so the change reaches all the way down. Renaming by hand in a deep document means finding every instance without missing one; doing it structurally means the tool cannot miss.

When this tool helps

  • Adapting an API response to the field names your own code expects.
  • Migrating a configuration file after a library renamed one of its options.
  • Normalising camelCase and snake_case key names across a payload.

How to use it

  1. Paste the JSON document.
  2. Enter the existing key name and the new name.
  3. Rename recursively through the structure.
  4. Copy the transformed JSON.

Accuracy, limits, and good practice

  • Matching is exact and case-sensitive, so userId and userid are different keys — check which one the document actually uses.
  • Renaming a key to one that already exists at the same level will collide, and one of the two values wins; check for that case first.
  • The values themselves are never touched, only the key names, so the data is unchanged even in a deeply nested document.
  • Rename against a copy of a real payload rather than a hand-typed sample; production data has optional fields and nesting that a sample never shows.

Frequently asked questions

Does it rename keys inside arrays of objects?

Yes. Recursion walks arrays and objects alike, so every object at any depth is covered.

Can I rename several keys at once?

One pair per pass. Run the tool repeatedly, feeding each result back in.

Does it change values that happen to match?

No, only object keys are renamed. A string value with the same text is left alone.

Will it rename a key inside a string value?

No, only object keys are changed. Text that happens to contain the same word is left exactly as it is.

Related tools on this site

Everything above runs inside this page. JSON Key Renamer needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

JSON 鍵名批量重新命名能做什麼

把整份 JSON 文件中某個鍵名的所有出現處一次改名,並遞迴走訪巢狀物件與陣列,讓變更貫穿到最底層。在深層文件裡手動改名,你得找齊每一處而不漏掉;用結構化的方式改,工具就漏不掉。

什麼時候用得上

  • 把 API 回應的欄位名,調整成自己程式期待的名稱。
  • 在函式庫改掉某個選項名稱後,搬遷既有設定檔。
  • 統一載荷中 camelCase 與 snake_case 的鍵名寫法。

使用步驟

  1. 貼上 JSON 文件。
  2. 輸入現有鍵名與新鍵名。
  3. 遞迴執行改名。
  4. 複製轉換後的 JSON。

精確度、限制與實務建議

  • 比對精確且區分大小寫,userId 與 userid 是不同的鍵——請先確認文件實際使用哪一個。
  • 把鍵改成同層已存在的名稱會發生衝突,兩個值只有一個留下,請先確認有無這種情況。
  • 值本身完全不動,只改鍵名,即使在很深的巢狀文件中資料也不會變。
  • 請拿真實載荷的副本來改名,而不是手打的樣本;正式資料有樣本永遠不會出現的選填欄位與巢狀結構。

常見問題

陣列裡的物件也會改名嗎?

會。遞迴同時走訪陣列與物件,任何深度的物件都涵蓋在內。

可以一次改多個鍵嗎?

一次一組。把每次結果再送回工具重跑即可。

剛好相同的「值」會被改到嗎?

不會,只改物件鍵名。文字內容相同的字串值不受影響。

會改到字串值裡的同名文字嗎?

不會,只改物件鍵名。剛好含有相同字詞的文字內容完全不動。

本站相關工具

以上步驟全部在這個頁面內完成,JSON 鍵名批量重新命名 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。