How to remove H1 Element from HTML

I’m trying to remove an H1 Element from HTML. I thought I may be able to do this by using the Text Helper and replace the regex of <h1>.*<\/h1> with an empty string but I don’t know how to enter an empty string in the Replace Value. so this actually leads me to 2 questions:

  1. Is there a better way to remove an element from HTML?
  2. In case I simply want to remove some text from another text, how can I do this? Generally the equivalent of str.replace("my text", "") in JS.

Hi @Yaakov_Oranski,

I’ve been trying to do it with the Text Helper as well and, but I couldn’t find a way to set the replace value to an empty string.

I prefer using the code block to handle this task myself. The following code snippet should do the trick. Currently it simply removes the <h1> tags, but you might want to replace them with <p> tags depending on what you need for your output HTML.

Here’s the code to remove the <h1> tags:

// Define the entry point function as 'code'
export const code = async (params: any) => {
    // Function to remove <h1> and </h1> tags from a text
    function removeH1Tags(text: string): string {
        const regex = /<\/?h1>/gi;
        return text.replace(regex, '');

    // Assuming the text to process is passed as a parameter named 'inputText'
    const inputText = params.inputText || '';

    // Process the text
    const outputText = removeH1Tags(inputText);

    // Return the processed text directly
    return outputText;

Here are the screenshots showing the flow setup:


Template with the solution

1 Like

We will make it un required but you would need to remove the text helper step and add it again.


Would it also be possible to use a single Text Helper step to replace multiple distinct values within a single step?

For instance, in the screenshot provided, the regex is designed to match both <h1> and </h1>. However, it only replace the opening <h1> tag and not the closing tag.

Same goes for values that aren’t distinct:

Uploading a fix now.

fix released, you can simply use this to solve the original issue, cheers lads.

1 Like

Love the quick work, great job!

I appreciate the quick fix on this but it is not perfect, for a few reasons:

  1. The response removes the <h1> element, but keep a whitespace/empty row there. my expectation is to have that element removed and nothing else appearing instead of it. for example if I have the following
<h1>my h1 text</h1>
<h2>my h2 text</h2>

The response will be

<h2>my h2 text</h2>

Whereas I’m expecting

<h2>my h2 text</h2>
  1. Another thing is with the implementation of replace all instances. I feel like this should be an option on the operation and not apply to all automatically. there may instances where i’d like to remove one instance of <H1> but not all.

Hey there, yeah I see your points:

  1. if you would like to remove the end-line at the end you might need this instead:<h1>.*</h1>\n that way you also remove the end-line as well.
  2. We will make it an option on Sunday, cheers.

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