# Hexadecimal to ascii/string function

**URL:** https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141
**Category:** General
**Created:** [28 August 2020 10:32 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141 "2020-08-28T10:32:26Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://discourse.nodered.org/u/Roger)
#### Post date: [28 August 2020 10:32 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/1 "2020-08-28T10:32:26Z")

</div>

Hello, there is any function that converts directly from hex to ascii? I need to aply it in a function node.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [28 August 2020 10:46 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/2 "2020-08-28T10:46:54Z")

</div>

Hi, do you mean Hex to decimal?

---

<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: [28 August 2020 10:50 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/3 "2020-08-28T10:50:35Z")

</div>

Can you share an example of what you would like to convert to what?

There are various built-in functions on the String object and the Buffer object that can be used to convert between different representations of the same data. Just needs an example from you so we know exactly what you're looking for.

---

<div class="post-metadata">

### Author: ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://discourse.nodered.org/u/Roger)
#### Post date: [28 August 2020 10:59 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/4 "2020-08-28T10:59:59Z")

</div>

Yes, I need to convert characters, for example I'm receiving 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 , that it means Hello world! in ascii, this Hello world is what I want to share on screen.

---

<div class="post-metadata">

### Author: ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://discourse.nodered.org/u/Roger)
#### Post date: [28 August 2020 11:01 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/5 "2020-08-28T11:01:27Z")

</div>

Hi knolleary, I reply the same than the coment before, I hope it's usefull for you.

Yes, I need to convert characters, for example I'm receiving 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 , that it means Hello world! in ascii, this Hello world is what I want to share on screen.

---

<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: [28 August 2020 11:02 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/6 "2020-08-28T11:02:46Z")

</div>

> [@Roger](#):
>
> rs, for example I'm receiving 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 ,

And how exactly are you receiving that ascii?

Is it in a string: `"48656c6c6f20776f726c6421"`? Or some other format?

---

<div class="post-metadata">

### Author: ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://discourse.nodered.org/u/Roger)
#### Post date: [28 August 2020 11:07 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/7 "2020-08-28T11:07:42Z")

</div>

Yes, it's a payload that I receive with Lora node (the data comes from an arduino program adn in a future it will be temperatures), and the format as you say is a string.

---

<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: [28 August 2020 11:10 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/8 "2020-08-28T11:10:18Z")

</div>

Assuming that String is in `msg.payload`, then the following function will do it:

```auto
msg.payload = Buffer.from(msg.payload,"hex").toString()
return msg;

```

---

<div class="post-metadata">

### Author: ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://discourse.nodered.org/u/Roger)
#### Post date: [28 August 2020 11:17 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/9 "2020-08-28T11:17:34Z")

</div>

Perfect, thanks knolleary, I would try it with the mate who program the arduino in a few hours and I say something, but i seems good.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 September 2020 11:17 UTC](https://discourse.nodered.org/t/hexadecimal-to-ascii-string-function/32141/10 "2020-09-11T11:17:40Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
