# Can't write buffer to file in hex

**URL:** <https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201>\
**Category:** General\
**Created:** [2 March 2022 00:01 UTC](https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201 "2022-03-02T00:01:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [2 March 2022 00:01 UTC](https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201/1 "2022-03-02T00:01:46Z")

</div>

I have a hex buffer that I would like to write to a file. It seems no matter what type of encoding I try I can't get the File node to write it in hex.  
Setting File node to hex provides no new lines.  
Auto gives me the following.  
 ![Screen Shot 2022-03-01 at 4.52.32 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/819006b88c9080080be8aea2a2c7532d336abe38.png)  
 ![Screen Shot 2022-03-01 at 4.53.40 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/2184f7ff9db8f0255a4d63a6ba72681d79c28253.png)  
Desired output would be something like:  
e2 80 d bc f1 1 f3 38 1 1 13 44 e3

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [2 March 2022 00:15 UTC](https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201/2 "2022-03-02T00:15:40Z")

</div>

Hello .. you can try converting the Buffer to a `.toString("hex")` in a Function node  
before sending it to the File write node

```javascript
// msg.payload = Buffer.from("e2800dbcf101f33801011344e3", "hex") // test
msg.payload = msg.payload.toString("hex")
return msg;

```

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [2 March 2022 18:45 UTC](https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201/3 "2022-03-02T18:45:23Z")

</div>

Thank you!

---

<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:** [16 March 2022 18:46 UTC](https://discourse.nodered.org/t/cant-write-buffer-to-file-in-hex/59201/4 "2022-03-16T18:46:05Z")

</div>

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