# Using a string as hex not as string

**URL:** <https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974>\
**Category:** General\
**Created:** [25 June 2020 14:54 UTC](https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974 "2020-06-25T14:54:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bond246](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bond246/32/16460_2.png) [@Bond246](https://discourse.nodered.org/u/Bond246)\
**Post date:** [25 June 2020 14:54 UTC](https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974/1 "2020-06-25T14:54:57Z")

</div>

Hello,

in my flow i'm working with xml-files. The xml-file is translated to json so every xml-tag is already a json-key with string-value.  
One of the xml-values should not be a string-type it shout be hex:

```auto
31343a313532352e3036233030

```

When i use [http://string-functions.com/hex-string.aspx](http://string-functions.com/hex-string.aspx) and translate the above value i get the correct form:

```auto
14:1525.06#00

```

So what i want to do now is changing the type of the above string as hex so that i can transform it to a real string.

I read a lot of posts in this forum where someone wants to translate an already existing buffer. But in my case i don't have a buffer but node-red has the false data-type 🙂 Everytime i try to transform with tostring() the classes use my input as string.

Thanks and all the best,  
Bond

---

<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:** [25 June 2020 15:33 UTC](https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974/2 "2020-06-25T15:33:46Z")

</div>

See [this](https://discourse.nodered.org/t/convert-hex-string-to-float/28893/20)...

Essentially - you can use a function node

e.g.

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

```

Some proof...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/0583d70d936839f39424c57817271b60f56c362e.png)

---

<div class="post-metadata">

**Author:** ![Bond246](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bond246/32/16460_2.png) [@Bond246](https://discourse.nodered.org/u/Bond246)\
**Post date:** [25 June 2020 18:18 UTC](https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974/3 "2020-06-25T18:18:11Z")

</div>

thanks a lot!

---

<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:** [9 July 2020 18:28 UTC](https://discourse.nodered.org/t/using-a-string-as-hex-not-as-string/28974/4 "2020-07-09T18:28:46Z")

</div>

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