ForHosting KIT · Data & Files

HTML to text

Get only the words out of a piece of HTML: in the example, a heading, a red style rule, a paragraph and a script come back as Titulo Hola mundo, with the style and the script gone completely. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon

Raw HTML is full of markup a search index, a summarizer or a human reader never asked for.

Why stripping tags is harder than it looks

Raw HTML is full of markup that a search index, a summariser or a human reader never asked for. A quick strip of everything between angle brackets leaves behind the contents of scripts and style rules, mixed into the text as if they were words, and it glues together words from neighbouring tags. This tool removes script and style blocks together with everything inside them, replaces each remaining tag with a space, turns the non-breaking space into an ordinary one and collapses runs of spaces. In the example the colour rule and the alert disappear, and what remains is Titulo Hola mundo.

Where clean text helps, and what to expect

Clean text is what a site search should index, so that matches land on real content instead of markup. It is also what belongs in front of a language model, without wasted words, in a plain-text email digest, or in a tool that watches a page for changes and should not raise an alarm when only the markup changed. Expect one continuous run of text: headings, paragraphs and list items follow each other separated by spaces, without layout. If you need headings and lists to stay recognisable, a conversion to Markdown is the better fit.

Structure survives, tags don't

The difference between good extraction and a naive strip is what happens to structure: a heading should still start its own line, a bullet list should still read like a list, and a table row shouldn't collapse into one run-on sentence with no spaces between cells. HTML itself was never meant to carry meaning beyond layout — it's a presentation language from the early web, and browsers have spent thirty years being forgiving of malformed markup, which is exactly why a real parser handles edge cases that string replacement cannot.

Feeding a search index

A site search tool converts crawled HTML pages to clean text before indexing, so query matches land on real content instead of on markup artifacts.

Preparing context for a language model

A retrieval pipeline strips HTML from fetched web pages so only readable text goes into the model's context window, cutting wasted tokens.

Plain-text email digests

A newsletter aggregator converts each HTML article to text to build a lightweight plain-text summary email with no broken layout.

Content diffing over time

A monitoring tool extracts text from a page on each crawl and diffs the plain text, avoiding false positives from cosmetic markup changes.

Does it preserve paragraph and list structure?

Yes, paragraph breaks and list items are kept on separate lines instead of being collapsed into one run-on block of text.

Will it strip script and style tags too?

Yes, script, style and other non-visible elements are removed along with their content, so only readable text remains.

Can I use this to clean scraped pages for a search index?

Yes, that's one of its most common uses — stripping markup before indexing avoids false matches on layout code.

Is my HTML stored after processing?

No, submitted HTML and the extracted text are deleted after the retention window and never used for training.

Do words from neighbouring tags run together?

No. Every removed tag leaves a space behind, and runs of spaces are collapsed into one, so a heading followed by a paragraph reads Titulo Hola mundo rather than TituloHola mundo.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/data/html-to-text

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/data/html-to-text \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<p>Hola <b>mundo</b></p>"}'
{
  "html": "<p>Hola <b>mundo</b></p>"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "data.html_to_text",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb25
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This endpoint pulls the actual words out of the tags, keeping paragraph breaks and list order intact instead of dumping one flat wall of text.

Markup is noise for most downstream jobs

A scraped page, a saved newsletter or a CMS export all carry the same problem: the words you want are wrapped in div soup, inline styles, script tags and attributes that mean nothing to a language model, a search index or a plain-text digest. Stripping tags with a quick regex breaks the moment a script block or a comment contains a stray angle bracket, and it flattens headings and list items into one unreadable run-on. data.html_to_text parses the document instead of pattern-matching it, so the output reads the way a person skimming the page would read it.

What the request does

Send POST /data/html-to-text with the HTML source, and the response is a task_id while extraction runs in the background. The finished plain-text result — with paragraph breaks preserved and list items kept on their own lines — arrives through a signed webhook call or waits behind a signed link valid for 24 hours.

Where it fits in automation

Search indexing, retrieval pipelines feeding a language model, email digest generators and full-text diffing tools all want clean text, not markup, and none of them should be maintaining their own HTML parser to get it. Because the task is billed per request and never charged on failure, a crawler can push every fetched page through this endpoint without budgeting for wasted calls, and the async design means a batch of ten thousand pages just becomes ten thousand webhook deliveries arriving on their own schedule instead of one script blocking on each page in turn.

How do I convert HTML to text with the API?

POST your HTML to /data/html-to-text, keep the returned task_id, and collect the plain-text result by webhook or a signed link valid for 24 hours.

Is the HTML to text API free?

No, there is no free tier or trial; it costs $0.002 per request, and a failed extraction is never charged.

Can I process HTML in bulk?

Yes, submit one async task per document and collect each result by webhook as it completes, which suits large crawl batches.

Is this endpoint live?

Yes, data.html_to_text is live and accepting requests now.

Read the full KIT documentation →