# How to Add element to msg.payload

**URL:** https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361
**Category:** FAQs
**Created:** [22 September 2018 17:53 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361 "2018-09-22T17:53:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![onire77](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/onire77/32/2755_2.png) [@onire77](https://discourse.nodered.org/u/onire77)
#### Post date: [22 September 2018 17:53 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/1 "2018-09-22T17:53:30Z")

</div>

If I have

```
msg.payload = {
    Element1 :"One",
    Element2 : "Two",
    Element3 : "Three"  
}
return msg;

```

The output is: `{"Element1":"One","Element2":"Two","Element3":"Three"}`  
But now, If I want to add a new element, how do I do it?

For the output like this: `{"Element1":"One","Element2":"Two","Element3":"Three","Element4":"Four"}`

Thank you.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [22 September 2018 17:57 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/2 "2018-09-22T17:57:01Z")

</div>

try a google search 'json opject adding element to' and see what you find.

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [22 September 2018 18:07 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/3 "2018-09-22T18:07:33Z")

</div>

Understanding javascript objects is very important for using Node-RED.

I found the following tutorial very helpful  
[https://www.w3schools.com/Js/js\_objects.asp](https://www.w3schools.com/Js/js_objects.asp)

---

<div class="post-metadata">

### Author: ![onire77](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/onire77/32/2755_2.png) [@onire77](https://discourse.nodered.org/u/onire77)
#### Post date: [22 September 2018 20:38 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/4 "2018-09-22T20:38:21Z")

</div>

```
msg.payload = {
    Element1 :"One",
    Element2 : "Two",
    Element3 : "Three"  
}

msg.payload["Element4"]="Four"
return msg;

```

Thanks to all

---

<div class="post-metadata">

### Author: ![krk](https://avatars.discourse-cdn.com/v4/letter/k/4af34b/32.png) [@krk](https://discourse.nodered.org/u/krk)
#### Post date: [10 February 2020 01:18 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/5 "2020-02-10T01:18:57Z")

</div>

way to contribute

---

<div class="post-metadata">

### Author: ![biishop](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/biishop/32/46572_2.png) [@biishop](https://discourse.nodered.org/u/biishop)
#### Post date: [16 August 2021 12:06 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/6 "2021-08-16T12:06:46Z")

</div>

Plz, this is not usefull so ...

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 August 2021 12:30 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/7 "2021-08-16T12:30:53Z")

</div>

@biishop if you have a question, please open your own thread. Add detail related to your problem.

This post is over 2 years old.

Closing this thread as the answer by @onire77 is correct.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 August 2021 12:31 UTC](https://discourse.nodered.org/t/how-to-add-element-to-msg-payload/3361/8 "2021-08-16T12:31:09Z")

</div>


