# Formatting text output properly from a text source

**URL:** <https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999>\
**Category:** Ask for Help\
**Created:** [February 12, 2025, 8:25am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999 "2025-02-12T08:25:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 12, 2025, 8:25am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/1 "2025-02-12T08:25:10Z")

</div>

Hi,  
I have a column with a text output that was generated by AI.

Output:  
[  
“Question 1: Hi, there are several people who are laying out mats in the park. They seem to be enjoying conversations. Some of them are playing. Some of them are talking to each other. They are discussing and there are some people buying items from cars.”,  
“Question 2: There is a time when my family took me to a garden park and we picnicked there. I enjoyed the weather and directions.”,  
“Question 3: Community events can help strengthen relationships for the diversity. We can discuss the same topics. I think it’s important because it helps in understanding one another and preventing conflicts.”,  
“Question 4: I think strengthening the bonds between people in the community is important because it helps in understanding each other and preventing conflicts.”  
]

I want to format the output properly that results in the following.

Desired Formatting:

Question 1: Hi, there are several people who are laying out mats in the park. They seem to be enjoying conversations. Some of them are playing. Some of them are talking to each other. They are discussing and there are some people buying items from cars.

Question 2: There is a time when my family took me to a garden park and we picnicked there. I enjoyed the weather and directions.

Question 3: Community events can help strengthen relationships for the diversity. We can discuss the same topics. I think it’s important because it helps in understanding one another and preventing conflicts.

Question 4: I think strengthening the bonds between people in the community is important because it helps in understanding each other and preventing conflicts.

Is there an easy way to do this?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 12, 2025, 9:08am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/2 "2025-02-12T09:08:04Z")

</div>

What you have there is some JSON.

To extract each item on its own row:

- Number the rows in your table, starting at zero
- Make sure the JSON is applied to all rows in the table. You can use something like a Single Value or Lookup column for this, depending on where you have it.
- Add a JavaScript column using the following:

```auto
return JSON.parse(p1)[p2];

```

- In the above, `p1` is your JSON, and `p2` is the Row Index.

Here is what that looks like:

 ![CleanShot 2025-02-12 at 17.07.10@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/8/78d49cdd227ec143ab50505bcc7b0153c8fde0a3.png)

 ![CleanShot 2025-02-12 at 17.07.33@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/5/b5d19af8fe589fec0ec9bb2d88cfe3f917a8330a.png)

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 13, 2025, 7:51am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/3 "2025-02-13T07:51:17Z")

</div>

Thank you! I will try it.

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 13, 2025, 8:56am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/4 "2025-02-13T08:56:20Z")

</div>

I am not quite familiar with JS. Supposed if I want to extract all the content of the JSON to text without splitting into rows, what should by my Javascript code be like?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 13, 2025, 9:09am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/5 "2025-02-13T09:09:32Z")

</div>

Try the following:

```auto
return JSON.parse(p1).join('\n');

```

The `\n` causes each string to be output on a separate line. If you don’t want that, you can just remove it.

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 13, 2025, 9:34am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/6 "2025-02-13T09:34:24Z")

</div>

> [@Darren\_Murphy](#):
>
> `return JSON.parse(p1).join('\n');`

Thanks! I tried and gave an error.

### Function Error

SyntaxError: “undefined” is not valid JSON

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 13, 2025, 9:38am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/7 "2025-02-13T09:38:02Z")

</div>

Can you show me a screen shot?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [February 13, 2025, 11:35pm UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/8 "2025-02-13T23:35:18Z")

</div>

![CleanShot 2025-02-14 at 06.34.54@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/b/5b2cfcebd6f36c73636fcfad36268e28ca151e22.png)

 ![CleanShot 2025-02-14 at 06.35.01@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/8/68fbfb115bfdaebfc603f5060ae39839bbec6b2b.png)

I tried with manual p1 input and it works fine.

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 15, 2025, 5:03am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/9 "2025-02-15T05:03:26Z")

</div>

Ah, I think I misunderstood what you mentioned. I will try it again. Thank you!

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 19, 2025, 7:56am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/10 "2025-02-19T07:56:57Z")

</div>

> [@Darren\_Murphy](#):
>
> `return JSON.parse(p1).join('\n');`

I understood what you are saying now and I got my first use case resolved. Now I now have another separate formatting problem that is related. I am trying to split each URL into different data row for further processing. Currently it is obtain as source below. I don’t know an easier way to do this (if there is a more straight forward way) but one way is to use what we just discussed, to convert to a JSON array and extract this through the same example as my very first use case. I attempted a javascript and was not successful.

input.split(‘,’).map(item =\> item.trim());

Original source:  
[https://storage/MI4E8iLr1AXkKl.jpg](https://storage/MI4E8iLr1AXkKl.jpg), [https://storage/dyqN9ZS6HAm.jpg](https://storage/dyqN9ZS6HAm.jpg), [https://storage/m0v9k3M5LkY3SHo.jpg](https://storage/m0v9k3M5LkY3SHo.jpg)

Target:  
[“[https://storage/MI4E8iLr1AXkKl.jpg](https://storage/MI4E8iLr1AXkKl.jpg)”, “[https://storage/dyqN9ZS6HAm.jpg](https://storage/dyqN9ZS6HAm.jpg)”, “[https://storage/m0v9k3M5LkY3SHo.jpg](https://storage/m0v9k3M5LkY3SHo.jpg)”]

Can you kindly advise please?

I even tried RegExReplace using excel formula, and I did get it working in excel but glide does not seems to recognize the formula.

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 19, 2025, 8:12am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/11 "2025-02-19T08:12:33Z")

</div>

Managed to get it working using this javascript. Would be curious if there is a easier way without using coding.

const urls = p1.split(‘,’).map(url =\> url.trim());

const result = “[” + urls.map(url =\> `"${url}"`).join(", ") + “]”;

return result;

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 19, 2025, 8:45am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/12 "2025-02-19T08:45:39Z")

</div>

> [@noviceplayer](#):
>
> Managed to get it working using this javascript. Would be curious if there is a easier way without using coding.

In this case, yes there is. You can use a combination of Split Text and JSON Template columns:

 ![CleanShot 2025-02-19 at 16.43.26@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/f/cfa679cfbafa232673f98f915b50e6d7c2349f9f.png)

The Split Text converts the joined list to an array, and then you simply pass that to the JSON template column like so:

 ![CleanShot 2025-02-19 at 16.45.10@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/f/dfd8a98e6569478f61296551daad66067ac95bf8.png)

---

<div class="post-metadata">

**Author:** ![noviceplayer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/noviceplayer/32/20374_2.png) [@noviceplayer](https://community.glideapps.com/u/noviceplayer)\
**Post date:** [February 19, 2025, 9:49am UTC](https://community.glideapps.com/t/formatting-text-output-properly-from-a-text-source/79999/13 "2025-02-19T09:49:08Z")

</div>

okay I will try it. Thanks again!
