Sample code for 30+ languages & platforms
JavaScript

Convert HTML to plain-text

See more HTML-to-XML/Text Examples

Demonstrates how to convert HTML to plain-text.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

var h2t = new CkHtmlToText();

// Set the HTML:
var html;
html = "<html><body><p>This is a test.</p><blockquote>Here is text within a blockquote</blockquote></body></html>";

var plainText;

plainText = h2t.ToText(html);

console.log(plainText);

// The output looks like this:

// This is a test.
// 
//     Here is text within a blockquote