# How to get boolean from JSON node to LED node

**URL:** <https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280>\
**Category:** General\
**Created:** [14 June 2026 04:52 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280 "2026-06-14T04:52:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [14 June 2026 04:52 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/1 "2026-06-14T04:52:06Z")

</div>

Just started learning Node Red and I'm having great difficulty trying to turn an LED on/off based on a value in a JSON block.

I put the following in an INJECT node:  
{"voltage": 30,"heateron":true}

The INJECT node connects to a JSON node which then connects to a GAUGE node.  
My gauge works fine when I use msg.payload.voltage  
However, I cannot do the same with an LED node, example msg.payload.heateron

So how do I get the boolean true/false value from the JSON node to turn on the LED ?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 June 2026 05:09 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/2 "2026-06-14T05:09:50Z")

</div>

Welcome to the Forum.

The `json` node isn't necessary here, as `msg.payload.voltage` and `msg.payload.heateron` will handle the relevant values directly from the JavaScript object.

 ![isolate_value](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c174e999d56c736c5fad05990e01fd843effc484.jpeg)

```auto
[{"id":"dcadfbbcf13f3955","type":"tab","label":"Flow 5","disabled":false,"info":"","env":[]},{"id":"10610ae81f65d607","type":"inject","z":"dcadfbbcf13f3955","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"voltage\":30,\"heateron\":true}","payloadType":"json","x":190,"y":240,"wires":[["e7d4dcf5245de1bf","66ed6e4c48f4aab8"]]},{"id":"e7d4dcf5245de1bf","type":"debug","z":"dcadfbbcf13f3955","name":"Isolate voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.voltage","targetType":"msg","statusVal":"","statusType":"auto","x":380,"y":200,"wires":[]},{"id":"66ed6e4c48f4aab8","type":"debug","z":"dcadfbbcf13f3955","name":"Isolate heateron","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.heateron","targetType":"msg","statusVal":"","statusType":"auto","x":380,"y":260,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [14 June 2026 08:13 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/3 "2026-06-14T08:13:52Z")

</div>

Thanks Dave, but I'm afraid I'm just left more confused. There does not appear to be anywhere in the LED node to use msg.payload.heateron so not sure how I can use it.  
From what I've read, the LED node expects either a true or false input so somehow I need to read the heateron boolean value and get that "injected" into the LED node.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 June 2026 08:20 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/4 "2026-06-14T08:20:08Z")

</div>

I'm not wanting to push out @dynamicdave and his help.

(No, I haven't looked at the code he posted)

Open the `LED` node and change it from just `payload` to `payload.heateron`

I think that may be a reason it isn't working.

(But as I haven't seen your code either, I can't be sure.)

The _payload_ is a rather generic term. (Nothing wrong with using it though)

But usually the payload is a _simple_ thing like `true/false` or stuff like that.  
But here it is a `json` message which means `payload` doesn't exist in the usual format/strucutre.

It is now `msg.payload.heateron` and `msg.payload.voltage`

So you need to look at the more specific `payload.heateron` part

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 June 2026 08:20 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/5 "2026-06-14T08:20:35Z")

</div>

Use a change node to move msg.payload.heaton to msg.payload.

As a beginner you may benefit form watching the [essentials videos](https://m.youtube.com/watch?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6&v=ksGeUD26Mw0&embeds_referring_euri=https%3A%2F%2Fnodered.org%2F&source_ve_path=OTY3MTQ&feature=emb_imp_woyt), they have a great deal of information that will help you as a beginner with node-red.

By the way welcome to the forum.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 June 2026 08:20 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/6 "2026-06-14T08:20:43Z")

</div>

If you look at the LED node you'll see it expects the true/false to be in `msg.payload`, so you need to move the property to the correct place - with a `change` node.

**Note** : This is the LED node for **Dashboard-1** (D2 may be different).

 ![LED_node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6aad287ee54de1501827b0e1b034161475553fc6.jpeg)  
 ![sunday_screenshot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/7/17105ec7c2401fba35e1f304acf4bb731098ef03.jpeg)  
Here's the above demo flow - just **IMPORT** it and have a play.

```auto
[{"id":"dcadfbbcf13f3955","type":"tab","label":"Flow 5","disabled":false,"info":"","env":[]},{"id":"10610ae81f65d607","type":"inject","z":"dcadfbbcf13f3955","name":"voltage = 3, heateron = true","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"voltage\":30,\"heateron\":true}","payloadType":"json","x":160,"y":200,"wires":[["4685871be5d4e500"]]},{"id":"4685871be5d4e500","type":"change","z":"dcadfbbcf13f3955","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.heateron","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":240,"wires":[["35c18b511d14be8e","8afcc9e196feecfe"]]},{"id":"8afcc9e196feecfe","type":"ui_led","z":"dcadfbbcf13f3955","order":2,"group":"29bb735723a8be77","width":0,"height":0,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"","x":590,"y":240,"wires":[]},{"id":"35c18b511d14be8e","type":"debug","z":"dcadfbbcf13f3955","name":"LED state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":300,"wires":[]},{"id":"b95c753607250817","type":"inject","z":"dcadfbbcf13f3955","name":"voltage = 3, heateron = false","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"voltage\":30,\"heateron\":false}","payloadType":"json","x":160,"y":280,"wires":[["4685871be5d4e500"]]},{"id":"29bb735723a8be77","type":"ui_group","name":"dashboard_group","tab":"246a538c.3d84b4","order":null,"disp":true,"width":6},{"id":"246a538c.3d84b4","type":"ui_tab","name":"SMART Home - lighting","icon":"home","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [14 June 2026 10:38 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/7 "2026-06-14T10:38:33Z")

</div>

> [@beefy](#):
>
> However, I cannot do the same with an LED node, example msg.payload.heateron

The problem is like I mentioned in my opening post:  
_"However, I cannot do the same with an LED node, example msg.payload.heateron"_

There is no value box in the LED node where you can alter what the message is. I therefore cannot use msg.payload.heateron directly in the LED node.  
The gauge node is different and no problem, as there is a value box and I change it from "msg.payload" to "msg.payload.voltage" and the gauge works as expected. Just can't do the same thing in the LED node.

---

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [14 June 2026 10:41 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/8 "2026-06-14T10:41:08Z")

</div>

Aha, that's it Dave, that worked a treat.  
It's very sneaky in that change node that I don't change the value to a boolean but instead it gets changed to msg.payload.heateron.  
Yes, looks like I've got a lot to learn.

Thanks to all of you for the kind help, and for the welcomes. Nice to be here.

Keith

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 June 2026 11:01 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/9 "2026-06-14T11:01:59Z")

</div>

Glad you have got it working.

The change node is changing the position of the property in the payload so it matches the LED node's requirements of where it expects the property to be. Happens a lot in Node-RED.

As @E1cid suggested - have a look at the Essential Videos - well worth the time and energy.

---

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [15 June 2026 05:35 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/10 "2026-06-15T05:35:03Z")

</div>

Thanks for the extra info Dave. Already started watching the videos.

Keith

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 June 2026 07:25 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/11 "2026-06-15T07:25:33Z")

</div>

I've just asked ChatGPT to create an illustration of how a JavaScript object is used in Node-RED.

 ![example_of_Json_in_NODE-RED](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/da0abd3128005ce4afa00b64e292ddaca0f378f8.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 June 2026 07:52 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/12 "2026-06-15T07:52:15Z")

</div>

That isn't a JSON object, it is a JavaScript object. JSON is always a string.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 June 2026 10:15 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/13 "2026-06-15T10:15:00Z")

</div>

OK - point taken.  
Here's another go with a clearer distinction between a JavaScript Object and a JSON string.

 ![javascript_object_and_json](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c2d0f882cc9cfa69508c0a1c53347ccfae0d184d.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 June 2026 11:06 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/14 "2026-06-15T11:06:53Z")

</div>

Perfect 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 June 2026 15:03 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/15 "2026-06-15T15:03:09Z")

</div>

… maybe worth noting that some nodes can do the conversion for you, eg mqtt nodes.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 June 2026 15:14 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/16 "2026-06-15T15:14:48Z")

</div>

Well spotted.  
I just use MQTT-In and MQTT-Out nodes and accept they do the conversion for me.

Just to expand on @dceejay comments a bit further...

`MQTT-OUT node`  
 ![monday_mqtt-out](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/77277b8ebc76f5b0b87377a2b9dcbc70e47f6c2e.jpeg)  
`msg.payload is` used as the payload of the published message. If it contains an Object it will be converted to a JSON string before being sent. If it contains a binary Buffer the message will be published as-is.

`MQTT-IN node`  
Can be set to output the incoming message in different formats.

 ![monday_mqtt-in](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8cd45a3109ad610a910defa3154bf8c967c85eaf.jpeg)  
In my NR flows, I usually leave it as Auto Detect (parse JSON object, string or buffer).

---

<div class="post-metadata">

**Author:** ![beefy](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@beefy](https://discourse.nodered.org/u/beefy)\
**Post date:** [15 June 2026 16:37 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/17 "2026-06-15T16:37:15Z")

</div>

It's great to see a Javascript object and a JSON object side by side. Not a great deal of difference.

Also good to know about the MQTT node being able to automatically detect a JSON object. I'm learning all this for monitoring/controlling ESP32 microcontrollers over the web, and I'll be using MQTT. Initially I thought I'd have to use a JSON node to convert the JSON object I'd be sending from a microcontroller, but that looks un-necessary now.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 June 2026 17:23 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/18 "2026-06-15T17:23:52Z")

</div>

> [@beefy](#):
>
> I'm learning all this for monitoring/controlling ESP32 micro-controllers over the web

That is exactly like I do with my IoT students - using ESP32-S2-Mini and ESP32-C3-Super-Mini.

---

<div class="post-metadata">

**Author:** ![KristopherLeads](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kristopherleads/32/107231_2.png) [@KristopherLeads](https://discourse.nodered.org/u/KristopherLeads)\
**Post date:** [15 June 2026 22:01 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/19 "2026-06-15T22:01:15Z")

</div>

The number of times I've been caught out by that _despite doing this as a career_ is wild. Definitely not just a you thing!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 June 2026 10:13 UTC](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280/20 "2026-06-16T10:13:12Z")

</div>

> [@beefy](#):
>
> It's great to see a Javascript object and a JSON object side by side. Not a great deal of difference.

There is a big difference between them. In fact this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6b49b8a39443a5460880bd5bc6b647cdf23124e.png)

Is not actually a javascript object, it is a visualisation of a js object. The object itself is a complex arrangement of data in the computer, arranged in a way that is easy for the software to understand. The visualisation above is a representation of that data in a way that is easy for humans to understand.

Similarly this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/431f8c27c2004786a802f3e617424375b43c54ca.png)

Is not a string, it is a visualisation of a string. The string itself is a sequence of bytes in memory containing the text shown. The main purpose of a JSON string is to provide a simple version of the complex js object that can easily be moved about from one piece of s/w to another (via MQTT for example) or for storing, in a file for example.

[Next page](https://discourse.nodered.org/t/how-to-get-boolean-from-json-node-to-led-node/101280.md?page=2)
