Bubble & OpenAI - How to remove unwanted line spaces
In this Bubble tutorial video we demonstrate how to remove unwanted line spaces from text generated by OpenAI in your Bubble app.
Quick Response to a Bubble Coaching Client's Question
This video is going to be really quick and it's a response to a question I've received from a Bubble coaching client I've been working with over the last few weeks and that is around when you receive a text back from the text generator OpenAI, their API, sometimes it contains unwanted line spaces. How do you remove that and get much nicer formatting of your text in Bubble?
Setting Up the OpenAI API Call
So I've got an API call set up to the OpenAI API and you have to check out another tutorial of how to do that but if I initialize or re-initialize the call and just wait for OpenAI to get back the data I've asked for, here is my AI generated text and you can see that there's a number of these backslash ends and that is a way of sending a line space in JSON and how then do I remove that?
The Problem with Find and Replace
Well I've seen some people trying to use find and replace and I think that doesn't work with Bubble because Bubble is almost too clever for that when Bubble receives this data back it knows that it's JSON, it knows that that's a line space and so it converts it into a line space for you.
The Solution: Using Trimmed in Workflow
So this is how I would approach getting rid of that unwanted line spaces before and after, sometimes after in this area here your API call. So if I click save and then I go onto a page here which I've got just a text box and an area to display my text, I'm going to delete that. I'm just going to show you very simply what you do in your workflow to format it like this.
Setting Up the Workflow
So I've got my API call here to OpenAI and then I'm just going to assume as is most commonly used that you're going to save the response. So I'll just call this AI text as a new data type and then call this text.
The Key Step: Using Trimmed
I said this would be brief, this is what the whole video has been leading up to. We go to results from the OpenAI call, we then go to choices because that's the different versions that OpenAI has returned. We go to the first item, we go to text and then yep very simple, this is what we're leading up to, we add in trimmed and trimmed removes any spaces like with the spacebar or any line spaces at the start and end of the text.
Conclusion
So hopefully that will help you remove any unwanted line spaces in your OpenAI generated text.
The best way to learn Bubble.io?
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 500+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.

Frequently Asked Questions
Find answers to common questions about our courses, tutorials & content.
No. Our Beginner Essentials course and AI No-Code Coach are designed for total newcomers. You’ll learn Bubble.io step by step - no coding required.
Simply type your question in plain English, and our AI taps into the entire video library to recommend the exact lessons you need. It’s like having a personal instructor on demand.
As long as you’re subscribed! With our monthly subscription, you get unlimited access to all 500+ videos, our growing course library, and the AI No-Code Coach.
Your subscription includes:
- Bubble Beginner Essentials – Get up and running fast.
- Build a ChatGPT Clone – Integrate AI into your no-code apps.
- Build Your SaaS Website with AI – Learn to create a scalable startup site.
Plus, new tutorials every week!
The AI No-Code Coach is your first stop for instant answers. If you need deeper help, you can book 1:1 Bubble coaching for expert guidance.
Yes! If you don’t see real progress within 14 days, let us know, and we’ll issue a full refund—no questions asked.
Absolutely. Your subscription is month-to-month, and you can cancel anytime—no lock-ins, no hidden fees.
Absolutely. Your subscription is month-to-month, and you can cancel anytime—no lock-ins, no hidden fees.
If you’re serious about building a successful SaaS startup, check out Mastery—our intensive mentorship program. Mastery goes beyond Bubble.io development and includes:
- 1:1 mentorship to fast-track your progress
- Marketing strategies tailored for no-code founders
- Product management insights to scale your startup
- Personalized support from experienced founders