# I can't convert text to lowercase

**URL:** <https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730>\
**Category:** General\
**Created:** [5 February 2023 11:49 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730 "2023-02-05T11:49:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 11:49 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/1 "2023-02-05T11:49:03Z")

</div>

Well - the gremlins are really mucking me up today

Tried using Blocky node to convert payload to lowercase - get error

Tried using a contrib node - got error

Tried using JSONata - got error

Will someone please just give me some working code!!!! #LOL

---

<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:** [5 February 2023 11:59 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/2 "2023-02-05T11:59:05Z")

</div>

An example flow with the text would be helpful, but the JSONata would be

```auto
$lowercase($$.payload)	

```

and Javascript

```auto
msg.payload = msg.payload.toLowerCase()
return msg;

```

---

<div class="post-metadata">

**Author:** ![stephenn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stephenn/32/66644_2.png) [@stephenn](https://discourse.nodered.org/u/stephenn)\
**Post date:** [5 February 2023 12:01 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/3 "2023-02-05T12:01:43Z")

</div>

I use a String Node to do that.

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

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:07 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/4 "2023-02-05T12:07:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1a0bbc6f4db5cc2ce2cf6bca20c540bc8427508.png)

I feel I've completely lost the ability to use NR this morning! ☹

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:07 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/5 "2023-02-05T12:07:59Z")

</div>

What is that string node?

---

<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:** [5 February 2023 12:17 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/6 "2023-02-05T12:17:10Z")

</div>

Are you saying you are still getting errors, if so export an example flow please.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:26 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/7 "2023-02-05T12:26:08Z")

</div>

Tried a simple test one and that worked so investigating why it doesn't work in the real flow

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

---

<div class="post-metadata">

**Author:** ![stephenn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stephenn/32/66644_2.png) [@stephenn](https://discourse.nodered.org/u/stephenn)\
**Post date:** [5 February 2023 12:27 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/8 "2023-02-05T12:27:43Z")

</div>

Sorry, I thought it was included in the standard Node Red installation. I was wrong.

You can find it here: [node-red-contrib-string (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-string)

It does all sorts of text manipulation. For example, I use it to manipulate the HTML file of another node.  
After getting the HTML text of the node, the String Node performs a Find & Replace for the hex string of the background color of the node. The flow then re-saves the node's HTML file. This changes the background color for the node from what the developer has setup.

It probably has 30+ different ways to manipulate a text string

---

<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:** [5 February 2023 12:31 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/9 "2023-02-05T12:31:27Z")

</div>

How is "red" generated?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:32 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/10 "2023-02-05T12:32:49Z")

</div>

Standdown everyone 🙂

So I had a switch node (this is a flow that has been working for a long time) but needed to now make it's input into lowercase

What I hadn't realised was that it was working on msg.payload.status not msg.payload so that is why everything was failing on me when trying to convert an object to lowercase

And unfortunately, the error messages didn't provide a clue to this 🙂

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/37733d81a2c8d493647dfe65118eb053f3719a2e.png)

---

<div class="post-metadata">

**Author:** ![stephenn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stephenn/32/66644_2.png) [@stephenn](https://discourse.nodered.org/u/stephenn)\
**Post date:** [5 February 2023 12:38 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/11 "2023-02-05T12:38:43Z")

</div>

> [@E1cid](#):
>
> An example flow with the text would be helpful, but the JSONata would be
> 
> ```auto
> $lowercase($.payload)	
> 
> ```
> 
> and Javascript
> 
> ```auto
> msg.payload = msg.payload.toLowerCase()
> return msg;
> 
> ```

I use Node Red so I don't have to learn JSONata or Javascript. 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:42 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/12 "2023-02-05T12:42:24Z")

</div>

I needed a quick solution so I was up for anything that would have worked!

That contib node is the node for the job 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c235926d0ba155e7eb90166c6a41997a7e27e329.png)

---

<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:** [5 February 2023 12:53 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/13 "2023-02-05T12:53:12Z")

</div>

The cognitive bias to remain ignorant to other code and ways is not an enlightened approach.

You could simply use a simple JSONata expression in the switch node property. Not that difficult to learn or understand. and makes the flow shorter and adds no more complexity in my opinion.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 12:58 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/14 "2023-02-05T12:58:45Z")

</div>

> [@E1cid](#):
>
> Not that difficult to learn or understand. and makes the flow shorter and adds no more complexity in my opinion.

I think the key phrase is "in my opinion" 🙂

It is very good for getting around missing core features but unless people use it a lot, it's syntax can easily trip people up

Your the forums leading JSONata expert so it is easy for you 🙂

Some people (like myself) are always looking for no-text-code solutions wherever possible 🙂

I do you use one JSONata expression a lot as the no-code workaround, for the missing "not contains" in the switch node, just causes messy wiring

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

But I always have to find an existing one and cut and paste it as I forget the syntax of it ☹

---

<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:** [5 February 2023 13:07 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/15 "2023-02-05T13:07:42Z")

</div>

> [@cymplecy](#):
>
> I think the key phrase is "in my opinion" 🙂
> 
> It is very good for getting around missing core features but unless people use it a lot, it's syntax can easily trip people up
> 
> Your the forums leading JSONata expert so it is easy for you 🙂
> 
> Some people (like myself) are always looking for no-text-code solutions wherever possible 🙂

1. No, not the key pharse. just politeness as to mitigate some offense that may be taken.
2. Simple JSONata and Javascript expression, are really not that difficult, but if you never try you will never improve. Mistakes are a learning tool/lesson.
3. Not really, but do have a keen understanding of it's nuances. This came from trial and error.
4. You are free to make any choices you like in this world. They may turn out not be the best choices however. You are still free to make them.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 February 2023 13:10 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/16 "2023-02-05T13:10:09Z")

</div>

I'm not going to argue with 1,2 and 3 as we'd be here all day 🙂

But 3 IS true 🙂 You ARE the forums leading JSONata expert 🙂

For which we are all grateful for 🙂

---

<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:** [5 February 2023 13:15 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/17 "2023-02-05T13:15:50Z")

</div>

> [@cymplecy](#):
>
> You ARE the forums leading JSONata expert

There are others not so vocal that would out shine me, I am the most prolific.

Enjoy the rest of the your weekend, as as you say we could discuss points to Ad Nauseam

---

<div class="post-metadata">

**Author:** ![stephenn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stephenn/32/66644_2.png) [@stephenn](https://discourse.nodered.org/u/stephenn)\
**Post date:** [5 February 2023 13:27 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/18 "2023-02-05T13:27:51Z")

</div>

> [@E1cid](#):
>
> The cognitive bias to remain ignorant to other code and ways is not an enlightened approach.

Not to start a philosophical argument but I am going to have a different opinion here. Node Red was created as a graphical tool. Therefore, if the Node Red folks or community developer has created a node that will do the job that would otherwise require JSONata or Javascript, why not use it? To take it to the extreme, I don't need to know the language that Microsoft Word was written to compose a letter.

This is my opinion. 😁

---

<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:** [5 February 2023 13:41 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/19 "2023-02-05T13:41:11Z")

</div>

> [@stephenn](#):
>
> Not to start a philosophical argument but I am going to have a different opinion here. Node Red was created as a graphical tool. Therefore, if the Node Red folks or community developer has created a node that will do the job that would otherwise require JSONata or Javascript, why not use it? To take it to the extreme, I don't need to know the language that Microsoft Word was written to compose a letter.

You can choose to do things anyway you wish, i am not arguing that.

I simple state that to choose to not look at other ways in not an enlightened approach.

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [5 February 2023 15:37 UTC](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730/20 "2023-02-05T15:37:04Z")

</div>

> [@cymplecy](#):
>
> msg.payload.status not msg.payload

😂 🤣 😂 🤣  
I'm glad I'm not the only one who does this! I may, however, hold the record for _how often_! We'll never know because I have nothing more to say on the subject.  
🤐

[Next page](https://discourse.nodered.org/t/i-cant-convert-text-to-lowercase/74730.md?page=2)
