# How to a comma into a payload string 123456 into 123,456

**URL:** <https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290>\
**Category:** General\
**Created:** [26 May 2021 15:28 UTC](https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290 "2021-05-26T15:28:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeSwaggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/deswaggy/32/42466_2.png) [@DeSwaggy](https://discourse.nodered.org/u/DeSwaggy)\
**Post date:** [26 May 2021 15:28 UTC](https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290/1 "2021-05-26T15:28:28Z")

</div>

Hello,

I'm trying to turn a string .payload from 123456 into 123,456.

The reason for adding the comma is to split-up and then use a split node to only change the second part ,456 using parts/index:# into a step then join the message back together, so the message would look like 123,1.

I have look for the solution but it likely so simple no-one has asked ☹  
If someone could enlighten me would be 💌

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 May 2021 15:40 UTC](https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290/2 "2021-05-26T15:40:44Z")

</div>

msg.payload = parseInt(msg.payload).toLocaleString();  
in a function node

> **[Number.prototype.toLocaleString() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)**
>
> The toLocaleString() method returns a string with a
> language-sensitive representation of this number.

Or parseFloat()

---

<div class="post-metadata">

**Author:** ![DeSwaggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/deswaggy/32/42466_2.png) [@DeSwaggy](https://discourse.nodered.org/u/DeSwaggy)\
**Post date:** [26 May 2021 15:49 UTC](https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290/3 "2021-05-26T15:49:46Z")

</div>

> [@E1cid](#):
>
> msg.payload = parseInt(msg.payload).toLocaleString();

This worked perfectly, thanks a bunch! Hours banging my head trying to work it out.

---

<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 June 2021 15:50 UTC](https://discourse.nodered.org/t/how-to-a-comma-into-a-payload-string-123456-into-123-456/46290/4 "2021-06-09T15:50:13Z")

</div>

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