# How to comment out a node?

**URL:** <https://discourse.nodered.org/t/how-to-comment-out-a-node/1106>\
**Category:** General\
**Created:** [26 June 2018 21:32 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106 "2018-06-26T21:32:34Z")\
**Posts on this page:** 9\
**Page:** 3

<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:** [27 April 2019 15:39 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/41 "2019-04-27T15:39:39Z")

</div>

> [@StrongTown](#):
>
> Ummm, why not just insert the following as the first line of the node you want to disable

Ummm why not read the thread?

e.g...

> [@Steve-Mcl](#):
>
> Untill someone can tell me how to halt flow of messages at runtime
> 
> - without adding some combination of inject & flow or global flags
> - without modifying / deploying (either breaking wire or adding a noop)  
> ...then it doesn't fit.

---

<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:** [27 April 2019 15:43 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/42 "2019-04-27T15:43:01Z")

</div>

> [@SteveMann](#):
>
> Like an enable pin on a chip?

Yeah. It would satisfy the runtime aspect of being able to enable/disable flow of messages, be built in & I believe could be implemented with backwards compatibility (e.g. if you import a newer flow JSON into an older node-red, it would simply render as an original link node)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 April 2019 17:11 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/43 "2019-04-27T17:11:09Z")

</div>

@Steve-Mcl As I've said, we will introduce the ability to disable any node.

It doesn't require any special nodes in your flow. It doesn't require any changes to the structure of your flow when you realise you want to disable something.

It _does_ require a deploy. It may not be exactly what you want, but it _is_ something that will address a number of requests and use cases.

You've said a few times that your proposal would not take much doing.

> [@Steve-Mcl](#):
>
> I don't think an inline clickable toggle (without injects and without flow or global state) of some kind would take much doing. Effort vs benefit is decent.

That simple isn't the case. We have no precedent for having a node in the middle of a flow that has a button or state that can be toggled in the editor without a deploy. The UI design work to get that right is not trivial.

I understand what functionality you want. I'm not ignoring it. But I do have to align it with work we already have underway and work we have planned.

Further down the line we have plans for a flow debugger (after 1.0 ships). I would not want to rush something in now that introduces new UI concepts at this stage of getting to 1.0, particularly when it overlaps with a whole area of functionality we want to focus on later this year.

But it certainly feeds into the bucket of functionality the flow debugger can enabled.

---

<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:** [27 April 2019 17:52 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/44 "2019-04-27T17:52:12Z")

</div>

> [@knolleary](#):
>
> That simple isn't the case. We have no precedent for having a node in the middle of a flow that has a button or state that can be toggled in the editor without a deploy. The UI design work to get that right is not trivial.

It's a perspective thing. Behind the scenes, the discarding of a msg seems trivial. I didn't wholey consider the UI part to be a large undertaking as we have the inject with a button on it. But if anyone knows it'd be you.

Keep up the good work.

---

<div class="post-metadata">

**Author:** ![kocherjj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kocherjj/32/20578_2.png) [@kocherjj](https://discourse.nodered.org/u/kocherjj)\
**Post date:** [8 June 2019 20:03 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/45 "2019-06-08T20:03:07Z")

</div>

Not sure if anyone is still looking into this but I had a similar need and here is what I came up with to resolve it. It doesn't meet the stated requirements but practically speaking it should work.

It can be dropped anywhere in the flow without editing in multiple places and is completely self contained. No need to define flow or global variables. If you want the gate to default to "Off" on deploy leave the "Inject once" box unchecked. If you prefer it defaults to "On" on deploy, check the box.

The only issue will be if you try to pass a message that consists of the string "switcharoo", since that's the trigger. I would imagine that is most unlikely but if so it should be easy enough to implement an alternative phrase.

I hope this can be of use to someone else.

![Flow%20Gate](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/55ef6bb1657bd532820bb325e751c3ad10246f71.png)

`[{"id":"3259db28.f50004","type":"inject","z":"d0598402.999e3","name":"Toggle Gate","topic":"","payload":"switcharoo","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":590,"y":300,"wires":[["14b0d29a.f9aa4d"]]},{"id":"14b0d29a.f9aa4d","type":"function","z":"d0598402.999e3","name":"Flow Gate","func":"var value = msg.payload;\nvar switchState = context.get(\"toggle\");\n\nswitch (value) {\n case \"switcharoo\":\n if (switchState === true){\n context.set(\"toggle\", false);\n node.status({fill:\"red\",shape:\"ring\",text:\"Off\"});\n }\n else {\n context.set(\"toggle\", true);\n node.status({fill:\"green\",shape:\"dot\",text:\"On\"});\n }\n break;\n default:\n if (switchState === true){\n return msg;\n }\n}","outputs":1,"noerr":0,"x":600,"y":360,"wires":[["9214e554.6a535"]]}]`

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [10 June 2019 16:16 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/46 "2019-06-10T16:16:52Z")

</div>

`<self-promotion>` At the cost of loading a contributed node, [node-red-contrib-simple-gate](https://flows.nodered.org/node/node-red-contrib-simple-gate) will give you the same capability with a bit more flexibility. `</self-promotion>`

---

<div class="post-metadata">

**Author:** ![fabi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fabi/32/76122_2.png) [@fabi](https://discourse.nodered.org/u/fabi)\
**Post date:** [2 November 2022 10:43 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/47 "2022-11-02T10:43:07Z")

</div>

Hi, i see that there is now the option to deactivate a node (which is very useful for UI-Nodes, because when you just disconnect it, you will still have a placeholder in the dashboard). As far as i know, it is only possible in the node-configuration. Is there also a way to dynamically deactivate single nodes by code for example by msg.payload properties?

---

<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:** [2 November 2022 11:00 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/48 "2022-11-02T11:00:45Z")

</div>

First off, welcome to the forum!

No there is no way to disable a node via something in the msg object. And if you did none of the nodes after that would run.

You could put a switch node before the node you want to disable and check something in the msg, then if it exist, bypass the node with a wire bypassing the next node. Otherwise the output of the switch would go to the next node.

Here is an example:

```auto
[{"id":"f10dab3c19a367f7","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"f1ad68685a5090d2","type":"inject","z":"f10dab3c19a367f7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":60,"y":120,"wires":[[]]},{"id":"af4995b295c02e2c","type":"inject","z":"f10dab3c19a367f7","name":"Don't skip","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"Skip","v":"No","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":240,"wires":[["c5de588e59935b89"]]},{"id":"efc20d9cdf1bfdb8","type":"debug","z":"f10dab3c19a367f7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":240,"wires":[]},{"id":"c5de588e59935b89","type":"switch","z":"f10dab3c19a367f7","name":"","property":"Skip","propertyType":"msg","rules":[{"t":"eq","v":"Skip","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":300,"wires":[["efc20d9cdf1bfdb8"],["c6a109b1cea45667"]]},{"id":"c6a109b1cea45667","type":"change","z":"f10dab3c19a367f7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"I wasn't skipped!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":320,"wires":[["efc20d9cdf1bfdb8"]]},{"id":"7b4be5bc3fd2385c","type":"inject","z":"f10dab3c19a367f7","name":"Skip","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"Skip","v":"Skip","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":360,"wires":[["c5de588e59935b89"]]}]

```

Lastly, this thread is over three years old and I’ll be closing it. If you still have issues open a new thread.

---

<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:** [2 November 2022 11:00 UTC](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106/49 "2022-11-02T11:00:52Z")

</div>



[Previous page](https://discourse.nodered.org/t/how-to-comment-out-a-node/1106.md?page=2)
