# How can I convert char code numbers to string characters?

**URL:** <https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610>\
**Category:** Dashboard\
**Created:** [21 August 2019 14:03 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610 "2019-08-21T14:03:44Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [21 August 2019 14:03 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/1 "2019-08-21T14:03:44Z")

</div>

Hi,

How can compare two input values and change output accordingly on dashboard. please help me.  
or  
combine all values and change into ASCII character.

Thanks.

Br,  
Devendra

---

<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:** [21 August 2019 14:11 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/2 "2019-08-21T14:11:28Z")

</div>

You are going to have to be a bit more specific if you want an answer.

Are the values in the same message?  
What do you mean by “combine all values and change into ASCII character.”?

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [21 August 2019 14:36 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/3 "2019-08-21T14:36:06Z")

</div>

Hello,

Are the values in the same message? - yes,

RFID values received in dashboard in byte format & i want to change into ASCII characters of a same value & show in a same row or line continue.

ex. 7273768367726982 convert into ASCII character as HILSCHER text

What i am getting see below screen shot.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6201bf1fe35a302315d8ecac6e40e068982bc5ab.png)

---

<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:** [21 August 2019 14:57 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/4 "2019-08-21T14:57:26Z")

</div>

> [@DSongra11\_forum.com](#):
>
> RFID values received in dashboard

How? Are you typing them in or are they already in Node-RED? You must be able to see them in a debug node (displayed in the debug panel)

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [21 August 2019 15:41 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/5 "2019-08-21T15:41:03Z")

</div>

Values coming from RFID tag, what i already write in RFID tag as HILSCHER ascii character. i am able to see the values in debug panel.

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

---

<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:** [21 August 2019 15:45 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/6 "2019-08-21T15:45:40Z")

</div>

So you said

> [@DSongra11\_forum.com](#):
>
> Are the values in the same message? - yes,

One message is : ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1c74f8443d2ae2f1765375b5b986773d8a4846f1.png)

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [21 August 2019 15:55 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/7 "2019-08-21T15:55:18Z")

</div>

so this value want to show on dashboard as ASCII Character.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [21 August 2019 16:00 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/8 "2019-08-21T16:00:35Z")

</div>

Take a look at the JavaScript functions for this:  
`String.fromCharCode` does what you’re looking for: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/String/fromCharCode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode)  
`<string>.charCodeAt` does exactly the reverse: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/String/charCodeAt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt)

Next I would look at pushing those messages together, get those characters in an array and do a join before displaying.

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [22 August 2019 08:04 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/9 "2019-08-22T08:04:00Z")

</div>

Hi

thanks, i am able made a string of RFID receiving data or value & showing on dashboard, but still output is not in ASCII character, could you please provide me code or node setting to convert decimal value as 7273768367726982 to ASCII character as a HILSCHER.

complete data string  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/54a9126b00a47b8777e5cb1d4487a74e972eb869.png)

when i remove tag from RFID device it is showing only updated 2 values (1335) not showing complete string.

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

---

<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 August 2019 08:16 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/10 "2019-08-22T08:16:19Z")

</div>

The post from @afelix showed you the javascript command to use.  
So how have you configured your function node to do this?

If you show us your code we can guide you so that you learn to do it correctly rather than just giving you the answer.

Post your function code here...

---

<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:** [22 August 2019 08:48 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/11 "2019-08-22T08:48:28Z")

</div>

Hi.

Just as @ukmoose and @afelix said, but in demo code instead...  
[jsbin.com/tiyilolapo/edit?js,console](https://jsbin.com/tiyilolapo/edit?js,console)  
.. That should put you on the right track

EDIT...  
I updated the title do be more descriptive of your question - for future users searching this & to help those who know how to do this to understand the topic before diving in

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [22 August 2019 09:46 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/12 "2019-08-22T09:46:34Z")

</div>

I am getting the same value.

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

Please look on my node red flow. what need to change.

[{"id":"7701343f.56242c","type":"debug","z":"2dd4e6c8.10259a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":480,"y":260,"wires":}]

---

<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 August 2019 09:48 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/13 "2019-08-22T09:48:59Z")

</div>

Unfortunately your flow isn't currently importable.Please read the following post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and then edit the above message.

Actually you have only exported your debug node, which isn't of use. Just copy and paste the function nodes contents (and format them as per the above link)

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [22 August 2019 09:51 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/14 "2019-08-22T09:51:11Z")

</div>

sorry,

```auto
[{"id":"2e6efd07.1f3ad2","type":"inject","z":"2dd4e6c8.10259a","name":"","topic":"","payload":"72","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":140,"wires":[["e314b0b.31a2b5"]]},{"id":"7701343f.56242c","type":"debug","z":"2dd4e6c8.10259a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":480,"y":260,"wires":[]},{"id":"e314b0b.31a2b5","type":"function","z":"2dd4e6c8.10259a","name":"ASCII","func":"\nconsole.log(String.fromCharCode(72))\n\nreturn msg;\n","outputs":1,"noerr":0,"x":320,"y":180,"wires":[["7701343f.56242c"]]}]

```

---

<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 August 2019 09:56 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/15 "2019-08-22T09:56:21Z")

</div>

So your function node contains the following

```auto
console.log(String.fromCharCode(72))

```

This isn't taking the value from your inject node, and won't pass the results on to your debug node.

I think its probably worth taking sometime to read the introduction flows.  
[https://nodered.org/docs/tutorials/](https://nodered.org/docs/tutorials/)  
Which will take you through the basics of how to program in Node-RED.

You need to modify something in the msg object, and to store the result in the msg object.

---

<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 August 2019 10:21 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/16 "2019-08-22T10:21:03Z")

</div>

change  
`console.log(String.fromCharCode(72))`  
to  
`node.warn(String.fromCharCode(72))`  
to see it in the debug tab

---

<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:** [22 August 2019 11:29 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/17 "2019-08-22T11:29:30Z")

</div>

Surely he just needs...

```auto
msg.payload = String.fromCharCode(msg.payload);
return msg;

```

@DSongra11_forum.com you need to understand a few fundamentals about node red.

- Each node passes a `msg` through the wires to connected nodes.
- in order for you to see what happened to the `msg` on-route, add debug nodes
- console.log (normally) logs to your browsers console (i.e. F12 Dev Tools, not the debug side-bar). Node-red `Function` nodes run on the server (inside node-red - not in your browser). Therefore `console.log()` wont appear in the browser console nor the debug side-bar - for that, use `node.warn("my warning text to appear in the debug side-bar")` as demonstrated by @zenofmud )

This topic is a must for people new to node red - [Working with messages : Node-RED  
 ](https://nodered.org/docs/user-guide/messages)

With that in mind...

- your inject will pass 72 in `msg.payload` to the function node
- the function node will be able to do something with `msg.payload` and pass it on to the next node (debug node in this case)
- the debug node shows you what is now inside the `msg`.

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [22 August 2019 15:22 UTC](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610/18 "2019-08-22T15:22:17Z")

</div>

I am a new on node red. but i did what i want to do on dashboard. Thank you so much.

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