HTML to Text Converter

फ्रीमियम
द्वारा Klorax | अपडेट किया गया 2 months ago | Text Analysis
लोकप्रियता

8.9 / 10

लेटेंसी

138ms

सेवा का स्तर

100%

Health Check

N/A

रीडमी

HTML to Text API Documentation

The HTML to Text API allows you to convert HTML content into plain text format. It provides a simple and efficient way to extract textual data from HTML documents, web pages, or any HTML-encoded content.

Convert HTML to Text

Endpoint

POST /api/convert

This endpoint accepts a JSON payload with the HTML content and converts it to plain text.

Request Parameters

Parameter Type Description
html string Required. The HTML content to be converted.
whitelist string[] Optional. A list of whitelisted HTML tags.
blacklist string[] Optional. A list of blacklisted HTML tags.

Example Request

POST /api/convert
Content-Type: application/json

{
  "html": "<h1>Hello, World!</h1><p>This is an example HTML content.</p>",
  "whitelist": ["h1", "p"]
}

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "text": "Hello, World! This is an example HTML content."
}

Error Responses

HTTP Status Code Description
400 Bad Request If the required html parameter is missing or invalid.
500 Internal Server Error In case of server-side errors.

Usage Notes

  • The API accurately parses HTML tags and extracts the textual data, excluding formatting and presentation elements.
  • The whitelist parameter allows you to specify the HTML tags that should be included in the conversion process.
  • The blacklist parameter allows you to specify the HTML tags that should be excluded from the conversion process.
  • The response contains the converted plain text in the text field.

Code Samples

JavaScript (fetch)

fetch('https://api.example.com/api/convert', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    html: '<h1>Hello, World!</h1><p>This is an example HTML content.</p>',
    whitelist: ['h1', 'p']
  })
})
  .then(response =&gt; response.json())
  .then(data =&gt; {
    console.log(data.text);
  })
  .catch(error =&gt; {
    console.error(error);
  });
फॉलोवर: 1
API निर्माता:
K
Klorax
Morax
API को रेट करने के लिए लॉग इन करें
रेटिंग: 5 - वोट: 1