# Convert buffer to string using core nodes

**URL:** https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556
**Category:** Share Your Projects
**Created:** [1 February 2023 12:54 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556 "2023-02-01T12:54:34Z")
**Posts on this page:** 7
**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: [1 February 2023 12:54 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/1 "2023-02-01T12:54:35Z")

</div>

Following last years string - \> buffer thread 🙂  
[https://discourse.nodered.org/t/convert-string-to-buffer/60755/12](https://discourse.nodered.org/t/convert-string-to-buffer/60755/12)

This year I wanted the other way so this is what I've done  
Split payload

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

and join back again

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

---

<div class="post-metadata">

### Author: ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)
#### Post date: [11 July 2024 14:01 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/2 "2024-07-11T14:01:29Z")

</div>

Hi, I'm trying to do the same thing with NR 4.0.2 :

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/020120e01679a95ec3c288ef9208743e0e100a76.png)  
_one of the payloads at the exit of the SPLIT node_

I see that the JOIN node is different:  
I have to check this box otherwise I have no payload:

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

So I do have a string payload at the end of JOIN node, but not as I would like: I'm waiting for "81733B0D....FF" instead I have this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/9/396feacabf1086af23e8a5c8b302a9f1d548b09e.png)  
there is a transformation in ASCII (probably ?) that I can't understand why?

---

<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: [11 July 2024 17:12 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/3 "2024-07-11T17:12:14Z")

</div>

Your data looks to be byte pairs of ascii with some odd chars up front.

Where are you getting the data from?

The buffer-parser nodes can do this without resorting to splits and joins (or you can use a function node - but the difficulty of that depends on the data format, byte-swapping etc)

If you want further help, paste a copy of the raw buffer data and tell me what is SHOULD be when represented as a string.

---

<div class="post-metadata">

### Author: ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)
#### Post date: [12 July 2024 07:17 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/4 "2024-07-12T07:17:38Z")

</div>

> [@Steve-Mcl](#):
>
> Where are you getting the data from?

the data comes from an iot device which sends via MQTT a buffer frame of bytes which I must assemble then separate according to a protocol.

> [@Steve-Mcl](#):
>
> The buffer-parser nodes can do this

yes that's exactly what I want to do with your "Buffer-parser"node :

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

Yes, I can also do it in a Function node (my javascript basics are starting to be good thanks to your help 😉 )

But, here the idea was to take what @cymplecy proposed with core nodes WITHOUT having to use a node-red-contrib :  
Example from a buffer : [0x79, 0x35, 0x32 ..., 0x33] To a string: "793532...33"

---

<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: [12 July 2024 07:25 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/5 "2024-07-12T07:25:06Z")

</div>

> [@SuperNinja](#):
>
> But, here the idea was to take what @cymplecy proposed with core nodes WITHOUT having to use a node-red-contrib :

Fair enough & good luck making something in less than 5 minutes in less than 5 nodes that is performant, extensible, easy to understand and reusable in place of a node specifically designed for this purpose.

---

<div class="post-metadata">

### Author: ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)
#### Post date: [12 July 2024 08:18 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/6 "2024-07-12T08:18:48Z")

</div>

> [@Steve-Mcl](#):
>
> Fair enough & good luck making something in less than 5 minutes in less than 5 nodes

that's why the proposal of a split followed by a join node was cool.. but obviously doesn't give the expected result... too bad. I will pass through your buffer-parser node (or Function node).

---

<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: [12 July 2024 08:36 UTC](https://discourse.nodered.org/t/convert-buffer-to-string-using-core-nodes/74556/7 "2024-07-12T08:36:45Z")

</div>

external systems, passing binary or ascii data often require specialise conversion that requires specialist routines that strip out control characters, CRCs, do data type conversions etc. If this were a simple, single string, then you can use core nodes (inluding a single function and probably a change+jsonata) but in most real life cases, interfacing real devices that often encode multiple data element in multiple differing formats (often for good reason, often for no good reason) - you will need specialist nodes or custom programming.
