Rename JSON Fields in n8n

Difficulty
1/10
Tags
EssentialsEdit Fields (Set)HTTP RequestExpressionsData Transformation

When working with APIs, the data you receive often has field names that don't match what you need. A field might be called temp when you want temperature_celsius, or nested deep inside the response when you need it at the top level.

The Edit Fields (Set) node lets you reshape data by creating new fields, renaming existing ones, or extracting values from nested structures. It's one of the most commonly used nodes in n8n.

In this challenge, you'll fetch weather data and transform the nested API response into a flat, clearly-named structure.

What you'll practice:

  • Using the Edit Fields (Set) node to create new fields
  • Referencing incoming data with expressions like $json.fieldName
  • Extracting nested data into a flat structure
  • Concatenating values in expressions

Your Task

Fetch current weather data from https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&current_weather=true and extract the nested fields into a flat, clearly-named output:

  • temperature_celsius: The current temperature (from current_weather.temperature)
  • wind_kmh: The wind speed (from current_weather.windspeed)
  • coordinates: Combine latitude and longitude in standard format (e.g., "52.52, 13.42")

Expected output format:

{
  "temperature_celsius": 4.7,
  "wind_kmh": 6.7,
  "coordinates": "52.52, 13.42"
}

Paste into n8n with Ctrl+V

Hints

  1. Add a Manual Trigger node to start the workflow
  2. Add an HTTP Request node with GET method to fetch from the URL above
  3. Add an Edit Fields (Set) node to create the new fields
  4. In Edit Fields, add three fields with the names from the task
  5. For nested data, use expressions like $json.current_weather.temperature
  6. For coordinates, set the field type to String and concatenate: $json.latitude and $json.longitude

Tip: Each field in Edit Fields has a type selector (String, Number, etc.). When combining values into text, use String.

Explanation

Why this solution works:

The weather API returns data in a structure that does not match what you need. Field names like temperature and windspeed are buried inside a current_weather object, and you want clearer names at the top level. The Edit Fields node lets you define exactly what your output should look like.

How it solves the problem:

  1. HTTP Request fetches the raw weather data. The API returns a JSON object with latitude, longitude, and a nested current_weather object containing temperature and windspeed. The data is nested and has names you want to change.
  2. Edit Fields creates your ideal output structure. You add three fields and tell n8n where to get each value:
  • temperature_celsius: Set to $json.current_weather.temperature. This reaches into the current_weather object and pulls out the temperature value. The new field name makes it clear what unit we are using.
  • wind_kmh: Set to $json.current_weather.windspeed. Same pattern: dig into the nested object and give it a clearer name.
  • coordinates: Set to $json.latitude and $json.longitude with a comma separator. This combines two separate values into one string.
  1. Edit Fields discards everything else. By default, the node only outputs the fields you explicitly define. The original nested structure, extra metadata, and unused fields all disappear. You get exactly the three fields you asked for.

Why this matters: Real-world APIs rarely give you data in the exact format you need. The Edit Fields node is how you bridge that gap: pull values from wherever they are, name them what makes sense for your workflow, and pass clean data to the next step.

Copy the Solution

Click below to copy the solution workflow to your clipboard. Then open n8n and press Ctrl+V anywhere on the canvas to paste it.

Login to see the exercise

Create an account to access challenges and track your progress.

Log in to see exercise