HTML to Text API

Strip tags from HTML or a web page URL and get readable plain text with line breaks preserved, plus word and character counts.

GETPOSThttps://apibox.io.vn/v1/html-to-text
Content & HTML▶ Try it online

Send HTML in the html field (JSON, form or query string), as a raw text/html body, or give a public url to fetch. The API removes script, style, noscript, template and head content, turns <br> and block elements (paragraphs, headings, list items, table rows, divs...) into line breaks, collapses repeated spaces and returns the text with its characters and words counts.

Unlike HTML to Markdown, no formatting is kept: the result is plain text suitable for search indexing, previews, SMS or text-only emails.

Limits: HTML up to 5 MB (request body up to 6 MB); URLs are fetched up to 5 MB with a 10 second timeout and at most 8 redirects. Only public http/https hosts are allowed.

Parameters

NameInTypeRequiredDefault
htmlbody|querystringnoHTML to convert (max 5 MB). Can also be sent as a raw text/html body. Required unless url is given.
urlbody|querystringnoPublic http/https URL of a page to fetch (takes precedence over html).

Example

curl -X POST "https://apibox.io.vn/v1/html-to-text" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Order confirmed</h1><p>Thanks for your order, <b>Alice</b>.<br>It ships tomorrow.</p><ul><li>1 x Keyboard</li><li>2 x Mouse</li></ul><style>p{color:red}</style>"}'

Response

{
  "text": "Order confirmed\nThanks for your order, Alice.\nIt ships tomorrow.\n1 x Keyboard\n2 x Mouse",
  "characters": 87,
  "words": 16
}

Use cases

  • Build the plain-text part of an HTML email
  • Index web page content in a search engine or database
  • Create text previews and snippets from rich content
  • Count words of a web page or article

FAQ

Are line breaks preserved?

Yes. <br> and block elements such as p, div, li, headings and table rows produce new lines; three or more blank lines are collapsed.

Is JavaScript and CSS content removed?

Yes. script, style, noscript, template and head elements are removed before the text is extracted.

Can I extract text directly from a URL?

Yes. Send url instead of html; the page is fetched (up to 5 MB) and converted.

Related APIs

Start with 1,000 free requests every month. Get free API key →