🧩

HTML to Text

Convert HTML to plain text.

POST 1 credit /v1/convert/html-to-text
curl -X POST "https://convert.toolkitapi.io/v1/convert/html-to-text" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"html": "<h1>Hello</h1><p>This is <a href=\"https://toolkitapi.io\">a link</a>.</p>", "preserve_links": true}'
import httpx

resp = httpx.post(
    "https://convert.toolkitapi.io/v1/convert/html-to-text",
    json={"html": "<h1>Hello</h1><p>This is <a href=\"https://toolkitapi.io\">a link</a>.</p>", "preserve_links": true},
)
print(resp.json())
const resp = await fetch("https://convert.toolkitapi.io/v1/convert/html-to-text", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"html": "<h1>Hello</h1><p>This is <a href=\"https://toolkitapi.io\">a link</a>.</p>", "preserve_links": true}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "text": "Hello\n\nThis is a link [https://toolkitapi.io].\n",
  "word_count": 4,
  "character_count": 42
}

Description

Convert HTML to plain text.

How to Use

1

1. POST a JSON body with `html` (or `url`).

2

2. Optionally set `preserve_links` and `preserve_tables`.

3

3. Read `text`, `word_count`, and `character_count` from the response.

About This Tool

Strips HTML tags and emits readable plain text. Blocks become paragraphs separated by blank lines; lists are flattened with bullets; headings are preserved as their text content.

Optional flags keep link URLs inline and preserve table structure — useful for plain-text emails, Slack messages, and search indexing.

Why Use This Tool

Frequently Asked Questions

Are scripts and styles stripped?
Yes — `<script>` and `<style>` content is removed entirely.
How are links represented?
With `preserve_links=true`, links appear as `text [url]`. Without the flag, only the link text is kept.
What about HTML entities?
All entities are decoded (`&amp;` → `&`, `&lt;` → `<`, etc.).

Start using HTML to Text now

Get your free API key and make your first request in under a minute.