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.
Ready to Transform Your App Idea into Reality?
Access 3 courses, 400+ tutorials, and a vibrant community to support every step of your app-building journey.
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 400+ 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.
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
14-Day Money-Back Guarantee
We’re confident this bundle will transform your app development journey. But if you’re not satisfied within 14 days, we’ll refund your full investment—no questions asked.
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Frequently Asked Questions
Find answers to common questions about our courses, tutorials & content.
Not at all. Our courses are designed for beginners and guide you step-by-step in using Bubble to build powerful web apps—no coding required.
Forever. You’ll get lifetime access, so you can learn at your own pace and revisit materials anytime.
Our supportive community is here to help. Ask questions, get feedback, and learn from fellow no-coders who’ve been where you are now.
Absolutely. If you’re not satisfied within 14 days, just reach out, and we’ll issue a full refund. We stand by the value of our bundle.
Yes, this is a special limited-time offer. The regular price is $350, so take advantage of the discount while it lasts!