Sample code for 30+ languages & platforms
Java

Convert HTML to plain-text

See more HTML-to-XML/Text Examples

Demonstrates how to convert HTML to plain-text.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.HtmlToText;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        HtmlToText h2t = new HtmlToText();

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

        String plainText = h2t.toText(html);

        System.out.println(plainText);

        // The output looks like this:

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