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.
Master Bubble & Launch Your MVP
Embark on your Bubble.io journey with our Free Access, or accelerate your progress with the 90-Day Pass for just $99.
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.
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.
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.
- Free Plan: Enjoy unlimited access to the Beginner Essentials course.
- 90-Day Pass: Unlock all 500+ videos and full AI functionality for 90 days. Afterward, you can subscribe at a great rate to keep building and learning.
Our AI No-Code Coach is your first stop. If you need deeper help, consider optional 1:1 coaching for personalized guidance. We also host occasional community events to share tips and celebrate wins together.
After your pass ends, you’re free to continue with a cost-effective subscription that includes ongoing AI No-Code Coach access and any future content updates.
Absolutely. If you don’t see real progress within 30 days of your 90-Day Pass, let us know, and we’ll issue a full refund—no questions asked.