Ido Toolbox icon

Ido Toolbox

A comprehensive collection of useful tools for data processing, text manipulation, and daily operations

Other Tool → HTML Parser

AI-generated

Overview

The node provides an "HTML Parser" operation under the "Other Tool" resource that extracts specific types of information from a given HTML string. It supports parsing to extract:

  • All text content (stripped of HTML tags)
  • Links (<a> tags with their URLs and link text)
  • Images (<img> tags with their source URLs and alt text)
  • Headings (<h1> to <h6> tags with their level and text)

This node is useful when you need to analyze or transform HTML content within your workflow, such as extracting all links from a webpage snippet, gathering image sources for further processing, or summarizing headings for document structure analysis.

Practical examples:

  • Extracting all hyperlinks from an email newsletter HTML to validate or track them.
  • Collecting image URLs from a product description HTML to download or optimize images.
  • Getting all headings from an article HTML to create a table of contents or summary.
  • Stripping all HTML tags to get plain text content for sentiment analysis or indexing.

Properties

Name Meaning
HTML String The raw HTML string input to parse.
Parse Type The type of information to extract from the HTML. Options:
- All Text: Extracts all textual content without HTML tags.
- Links: Extracts all anchor tags with their href URLs and link text.
- Images: Extracts all image tags with their src URLs and alt text attributes.
- Headings: Extracts all heading tags (h1 to h6) with their level and text content.

Output

The output JSON structure depends on the selected parse type:

  • All Text

    {
      "htmlString": "<input HTML>",
      "parseType": "text",
      "parsedData": {
        "textContent": "<all text content>",
        "characterCount": <number of characters>,
        "wordCount": <number of words>
      },
      "parsingSuccessful": true
    }
    
  • Links

    {
      "htmlString": "<input HTML>",
      "parseType": "links",
      "parsedData": {
        "links": [
          { "url": "<href>", "text": "<link text>" },
          ...
        ],
        "linkCount": <number of links>
      },
      "parsingSuccessful": true
    }
    
  • Images

    {
      "htmlString": "<input HTML>",
      "parseType": "images",
      "parsedData": {
        "images": [
          { "src": "<image src>", "alt": "<alt text or empty string>" },
          ...
        ],
        "imageCount": <number of images>
      },
      "parsingSuccessful": true
    }
    
  • Headings

    {
      "htmlString": "<input HTML>",
      "parseType": "headings",
      "parsedData": {
        "headings": [
          { "level": <heading level 1-6>, "text": "<heading text>" },
          ...
        ],
        "headingCount": <number of headings>
      },
      "parsingSuccessful": true
    }
    

If parsing fails, the node throws an error indicating failure to parse HTML.

Dependencies

  • No external services or API keys are required.
  • The node uses regular expressions internally to parse HTML strings.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Invalid or malformed HTML input: Since the parser relies on regex, extremely malformed or complex HTML might not be parsed correctly. Ensure the HTML string is well-formed.
  • Empty results: If the selected parse type returns empty arrays or zero counts, verify that the HTML string actually contains the relevant elements (e.g., links or images).
  • Error "Failed to parse HTML": This indicates an unexpected issue during parsing, possibly due to invalid input format. Check the HTML string for correctness.
  • Unknown parse type error: Should not occur if using the provided options; ensure the "Parse Type" property is set correctly.

Links and References

Discussion