how to strip html tags in javascript

var htmlString= "<div>\n <h1>Hello World</h1>\n <p>This is the text that we should get.</p>\n <p>Our Code World &#169; 2017</p>\n </div>";

var stripedHtml = htmlString.replace(/<[^>]+>/g, '');
var decodedStripedHtml = he.decode(stripedHtml);

// Hello World
// This is the text that we should get.
// Our Code World &#169; 2017
console.log(stripedHtml);

// Hello World
// This is the text that we should get.
// Our Code World © 2017
console.log(decodedStripedHtml);

3.75
4
Phoenix Logan 186120 points

                                    let strippedString = originalString.replace(/(&lt;([^&gt;]+)&gt;)/gi, &quot;&quot;);

3.75 (4 Votes)
0
3
2
Awgiedawgie 440220 points

                                    function stripHtml(html)
{
   let tmp = document.createElement(&quot;DIV&quot;);
   tmp.innerHTML = html;
   return tmp.textContent || tmp.innerText || &quot;&quot;;
}

3 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
js strip_tags how to strip html in js javascript to strip html tags strip out html tags javascript javascript strip paragraph tags strip_tags in javascript striptag javascript js strip html from text strip tags js js striptags javascript strip all html tags from string how to strip html tag from a string in javascript js strip p tags javascript strip tags function with ecluded javascript strip_tags equivalent how to strip tags js custom function to strip html tags on javascript strip tags using jsdom strip_tags() vs h() javascript js strip html tags and content strip html from string javascript strip html from text javascript strip_tags js strip certain tags js strip_tags javascript strip tag html javascript javascript striptags how to strip html tags in javascript javascript strip tags from html ja strip html tags strip html from a string javascript remove html tags text how to remove formatting from html in javascript how to remove tags in html string having html tags js strip all p tags in js regex for removing html tags javascript js html tag remove nodejs remove html tags from string python strip html tags clean html tags javascript how to remove html tags from text javascript nodejs strip html from string remove a html tag inside a string preview remove html tags filter out tags in string javascript remove html elements from sting javscript strip html code remove HTML from a string using javascript javascript remove html and css from string javascript remove tags from tag javascript remove subtags javascript string remove all html tags stripTags lodash remove string tag html js strip tag strip string javascript strip strong of html remove tag from html string javascript react strip html string strip html tags replace html tags in string How to nullify html as string javascript function to remove html tags from string javascript remove specific html elements regex javascript strip tags from tag es6 remove html tags in specific element remove all tags javascript remove tags inside javascript js strip tags js remove tags form closed javascript filter out html tags remove html between 2 tags javas how to replace html tag in typescript replace all html tags javascript javascript strip string remove all html tags from string in javascript strip js from html doc strp tags javascript clean js string from html tag node js remove html from string how to remove all html tags from a string in javascript remove html tags and text how to remove html tags from a string in javascript remove tags from string javascript striphtml javascript striptags js regex to remove html tags javascript remove html tags regex javascript packages to remove html tags from string in javascript nodejs strip html tags javascript html with html tags on string how to stipt word in javascript how can remove html tag from text nodejs remove .html from lin kjs how to remove tags from html js nodejs remove html from string clear created tags in js hot to remove &lt;p&gt; and &lt;/p&gt; tags from string javascript javascript regex remove html tags how to remove html tags from string javascript js remove html tags javascript remove all tags how to remove html tags from string in javascript javascript regex remove all html tags skip html javascript html tags not working in dom when tags in string js strp styling from html node js strip only some tags from string node js remove html tags from string remove html tags from string reactjs strip text from html js how to make strip html ember strip html remove all tags from string javascript remove given div tags in string javascript remove all div tags in string javascript js string remove html strip html tags code javascript javascript remove html tags javascript replace all html tags in string remove all html tags in javascript typescript remove html tags from string how to remove html encoding node remove tags from string php nodejs js remove all html tags javascript strip tags and it's content from string javascript strip tags from string parse html tags from string srtip tags javascript strip html tags in javascript javascript striptag javascript remove tags from text strip html tags typescript get span tags out of string with JS hide string coming without tags in javascript hide string without tags in javascript javascript remove tags from user input javascript remove html text strip html tags from string javascript nodejs strip html in string nodejs stripe html tags from text js strip html tags smartest way to remove a tag from string js node strip html strip tag js string accepting html tag string-strip-html typescript strip tag javascript identify html tag from string js how to show html tags as string in javascript how to strip html tags from string in javascript remove html from string javascript javascript remove html full elements from string javascript remove html elements from string remove first html tags from string javascript How to strip first HTML tags from string in JavaScript? remove first tag from html string javascript javascript remove all string with html tag nodejs filter out all html js strip htl tags js filter out all html tags from string javascript clean html to string remove html elements from string strip html tag javascript javascript strip_tags javascript how to strip html tags from string remove mark tags from text javascript javasccript striptags from string replace html tags from string javascript angularjs strip away html tags js string trim tag strip all html tags javascript javascript perform html tags from string remove tag from string javascript Use lodash to strip HTML Tags how to strip the html tags in 'typescript' how to strip the html tags in typescript how to strip html when copy javascript remove all the html tag from string js remove tags from text remove html from string how to remove html tags element in react js javascript remove all html tags from string strip html tag js get only some tag from string javascript delete tag html from string js remove tags html and adjust javascript remove html styling from string javascript remove all html javascript how to strip the html how strip div tags in react how to remove strip div tag in react js how to remove html tags in react js javascript remove html tag from string remove html tags javascript js strip html remove html from string js remove one tag from an html string in javascript strip html from string strip html encode for text javascript remove html from a string strip html string how to remove &lt;p&gt; tag from paragraph in nodejs javascript remove tags from string remove html tags from string javascript# typescript remove tags from string remove html to text with javascript js remove tags from string strip html js typescript clean html string javascript string remove tags remove last html tag from string in javascript javascript strip html tags strip tags in javascript strip tags html es6 remove html tags in es6 remove html tags in javascript javascript remove html code remove html tags from string typescript js replace html tags in string remove all html tags from string javascript js string remove html tags replace all html tags regex in react strip tags javascript how to replace all html tags in javascript remove all html tag from string node js javascript remove html tags from string nodejs remove html from string javaascript remove html markup from string how to remove html from a string js remove all html tags from string strip html tags javascript react remove html tags from string string remove tags javascript lodash strip html strip html tags js js remove html tags from string html strip tags javascript remove p tags from string javascript remove html tags from string js remove string from html tags in javascript javascript strip html Remove all available HTML tags from given string typescript trim html div javascript strip string of html tags how to replace html tags in strings nodejs remove any markup from string nodejs remove any markup javascript strip tag name remove html tag from string js strip html javascript javascript remove tag from string js stip tags javascript remove html tags from string regex remove all html tags from string javascript regex javascript strip tags php dymamic string into newline remove html tags from string javascript how to remove html tags in javascript strip HTML in js javascript strip out html tags from string javascript sstrip property for string tag tags javascript remove a tag in string javasceript remove &lt;a&gt; tag in string javascript remove html tags from string javascript remove html tags from string remove all html elements from string javascript strip html tags from string
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source