All guides

n8n HTML extraction: prepare text for AI

Extract target text from existing HTML and inspect selectors, arrays and cleanup.

AINavWritten / Updated Sources checked
On this page

At a glance

This guide explains one existing-data task from official node documentation. Establish input and receiver contracts, configure parameters and inspect output. Local checks use public synthetic data without running n8n or calling a model.

Checks from input to delivery

  1. Inspect input

    Check fields, formats and receiver prerequisites.

  2. Configure conversion

    Use the documented operation and actual fields.

  3. Inspect output

    Check count, types and boundaries before continuing.

Preserve original input and missing states at each stage.

Inspect the existing HTML field

Prepare an existing JSON item whose html field contains the document; this guide does not fetch third-party sites. The fixture has two p elements inside article containing Public A and Public B, with Menu in a separate nav. Preserve the input and decide whether the receiver needs all paragraphs or one string. Extraction does not authenticate the source content.

Set the source, selector and return type

Choose Extract HTML Content in the HTML node, set Source Data to JSON and JSON Property to html. For an existing HTML file, choose Binary and its actual Input Binary Field. Set Key to bodyText, CSS Selector to article p and Return Value to Text. Enable Return Array for multiple values. Attribute, HTML and Value have distinct meanings and do not substitute for body text.

Inspect omissions and text cleanup

For Text, Skip Selectors can omit selected descendants. Trim Values removes edge whitespace; Clean Up Text also processes line breaks and condenses consecutive whitespace. Compare with the original before passing bodyText to an AI step, especially for code and paragraph or table relationships. On empty output or changed counts, inspect the selector and input field before judging the source empty.

Only the synthetic fragment was checked locally

A local XML-compatible fragment check returned Public A and Public B from the two p elements and excluded nav text. It did not run n8n CSS selection, a node or a model. Inspect the actual bodyText type, count and source correspondence before downstream use. Stop on selector mismatch, missing input or lost required structure.

Article sources

Original editorial content; official descriptions and checking suggestions are distinguished.

  1. n8n · Official sources
    View details