# JSON number value to string

**URL:** <https://community.n8n.io/t/json-number-value-to-string/21894>\
**Category:** Questions\
**Tags:** node, set\
**Created:** [January 16, 2023, 1:39pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894 "2023-01-16T13:39:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dickhoning](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dickhoning/32/10415_2.png) [@dickhoning](https://community.n8n.io/u/dickhoning)\
**Post date:** [January 16, 2023, 1:39pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/1 "2023-01-16T13:39:19Z")

</div>

I’m trying to convert a number value (1) to a string (“1”).

I was expecting the Set function to already take care of this when selecting ‘String’ as the Value to Set. Tried adding “” in the value, as well as Javascript functions String and .toStrring(). And although the example, as well as the output in table form display “1”, the result remains 1 (without the “”). Any idea what I might be doing wrong?

 ![Screenshot 2023-01-16 at 14.32.05](https://europe1.discourse-cdn.com/n8n/original/3X/6/f/6f4184941ebe5f7a34ccca907ffaeaef711ccab3.png)

 ![Screenshot 2023-01-16 at 14.38.05](https://europe1.discourse-cdn.com/n8n/original/3X/e/f/efc7630b415a0eac101561e02741c087f5ab2d99.png)

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [January 16, 2023, 1:40pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/2 "2023-01-16T13:40:39Z")

</div>

“” + number should do it.

to clarify:

```auto
{{ "" + $json.field }}

```

---

<div class="post-metadata">

**Author:** ![dickhoning](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dickhoning/32/10415_2.png) [@dickhoning](https://community.n8n.io/u/dickhoning)\
**Post date:** [January 16, 2023, 1:58pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/3 "2023-01-16T13:58:02Z")

</div>

> [@BramKn](#):
>
> `{{ "" + $json.field }}`

unfortunately, it does not …

 ![Screenshot 2023-01-16 at 14.57.45](https://europe1.discourse-cdn.com/n8n/original/3X/5/5/55181a1e6898cce6eb7af5645c642fcd7944b768.png)

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [January 16, 2023, 2:01pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/4 "2023-01-16T14:01:41Z")

</div>

Weird, with simple 2 sets after eachother it does work. 🤔

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/9/3/93ab6b4dc029b6c11e7689eb522c138c7aab68f9.png)

edit: I just checked if it still works when the field name is the same. This is the case, so something else is going on here.

---

<div class="post-metadata">

**Author:** ![dickhoning](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dickhoning/32/10415_2.png) [@dickhoning](https://community.n8n.io/u/dickhoning)\
**Post date:** [January 16, 2023, 3:26pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/5 "2023-01-16T15:26:16Z")

</div>

indeed weird … also because the other way around (number to string) works, i.e.

```auto
{{ Number($json["id"]) }}

```

I’m trying to merge two datasets, where the id is dataset A is number and in dataset B is string. Would be nice if the Merge node would ignore the data type and would merge on the content …

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [January 16, 2023, 3:31pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/6 "2023-01-16T15:31:52Z")

</div>

Yes, this would be very nice indeed. I have the same issue with a lot of my data sets. I always turn the string into numbers so never noticed any issue with converting them.

Still no idea why the convert to string doesn’t work. have you tried (value).toString() without putting the “” around it?

---

<div class="post-metadata">

**Author:** ![dickhoning](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dickhoning/32/10415_2.png) [@dickhoning](https://community.n8n.io/u/dickhoning)\
**Post date:** [January 16, 2023, 3:54pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/7 "2023-01-16T15:54:19Z")

</div>

Yes, I think I’ve tried virtually everything 😉

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [January 16, 2023, 4:03pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/8 "2023-01-16T16:03:06Z")

</div>

Have you tried with static data?

Might be connected to my issue with the dates:

> [@Date weirdness: when retrieving a date (from mysql) the date cannot be used in following nodes expression](http://community.n8n.io/t/date-weirdness-when-retrieving-a-date-from-mysql-the-date-cannot-be-used-in-following-nodes-expression/21884):
>
> Hi There, We are having a strange issue. It was also mentioned in another topic but the poster marked it as resolved. [http://community.n8n.io/t/global-execution-dont-give-same-output-than-execusion-node-by-node/21852](http://community.n8n.io/t/global-execution-dont-give-same-output-than-execusion-node-by-node/21852) We cannot use a date calc on a timestamp returned from MySQL, it does run when you run the node itself and is all good. But when running the complete workflow it does not return any value. This also is the case for the split function etc. It seems like the field simply does not …

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [April 16, 2023, 4:03pm UTC](https://community.n8n.io/t/json-number-value-to-string/21894/9 "2023-04-16T16:03:26Z")

</div>

Closed on April 16, 2023, 4:03pm UTC

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