HTML Text Extraction
Extracts the main readable content from HTML or XHTML documents using trafilatura with content-boundary detection.
Extracts the main readable text of an HTML document with trafilatura, dropping navigation, scripts, comments and other boilerplate; tables are kept.
Strips navigation chrome, scripts, style blocks, advertising containers, cookie banners, headers, footers, and comment threads while preserving the substantive article body.
Features:
- Boilerplate removal: Detects and removes page chrome based on trafilatura's trained extractors, tuned for modern CMS and blog layouts.
- Structural preservation: Retains headings, paragraphs, ordered and unordered lists, and blockquotes in document order.
- Precision/recall tradeoff:
favor_precisiontoggles between aggressive cleanup (default, fewer false positives) and permissive extraction (recovers content on unconventional layouts). - Metadata extraction: Pulls title, canonical URL, author, publish date, site name, and language when surfaced by the page's meta tags, Open Graph, or JSON-LD.
- Inputs: Accepts raw HTML as a string, base64-encoded HTML, or a local file path.
How it works
- Reads
content(raw HTML string),content_base64andfile_pathfrom the node config, falling back to the upstream payload; fails onerrorwhen all three are missing. - Uses the first source present in this order:
content,content_base64(decoded as UTF-8),file_path. - Runs trafilatura with comments excluded, tables included, no formatting and
favor_precisionfrom the config (defaulttrue). - Routes to
emptywhen no text was extracted, otherwise toextracted.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-clean-page",
"label": "Clean page",
"operator_slug": "ai.html.extract.text",
"operator_version": "1.0.0",
"config": {
"content": "{{ $json.body }}",
"favor_precision": true,
"execution": {
"timeout_ms": 60000
}
}
}{
"ok": true,
"data": {
"text": "Release notes\nThe new version adds export to CSV.",
"chars": 48,
"empty": false,
"method": "trafilatura",
"metadata": {
"input_chars": 18342
}
},
"port": "extracted"
}Configuration
-
favor_precisionboolean Optional -
Trade recall for precision. Turn off if content is getting truncated.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
content, content_base64, file_path - Not declared in the config schema, but read from the node config first and then from the upstream payload. Usually you map them from the previous node with expressions.
-
favor_precision - Only
falseturns it off; any other value, including a missing key, keeps precision mode. Turn it off when real content is being cut. -
execution - Only
execution.timeout_msis read (fallback 60000 ms).retryOnFail,maxTries,waitBetweenTries,continueOnFailandalwaysOutputDataare ignored.
Output ports
extracted default Main text was found.
{
"text": "Release notes\nThe new version adds export to CSV.",
"chars": 48,
"empty": false,
"method": "trafilatura",
"metadata": {
"input_chars": 18342
}
}empty trafilatura found no main content (very short pages, pages that are mostly navigation).
{
"text": "",
"chars": 0,
"empty": true,
"method": "trafilatura",
"metadata": {
"input_chars": 412
}
}error No input was given or the script failed.
{
"error": "content, content_base64, or file_path is required.",
"stderr": ""
}In expressions
What a later node can read from this node's output with $("HTML Text Extraction").item.json.<path> (write your node's label instead of HTML Text Extraction). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through extracted, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("HTML Text Extraction").item.json.text | ||
$("HTML Text Extraction").item.json.chars | ||
$("HTML Text Extraction").item.json.empty | ||
$("HTML Text Extraction").item.json.method | ||
$("HTML Text Extraction").item.json.metadata | ||
$("HTML Text Extraction").item.json.metadata.input_chars | — |
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
content, content_base64, or file_path is required. | error | None of the three sources was found in the config or the upstream payload. |
Either content, content_base64, or file_path is required | error | Raised by the script when only file_path was given and the file does not exist on the host. |
Python timed out after <timeout_ms>ms | error | The script exceeded the node timeout. Raise execution.timeout_ms or send a smaller file. |
Python stdout exceeded MAX_STDOUT_BYTES (52428800 bytes) | error | The result (text or base64 files) is larger than the 50 MB cap. Split the input upstream. |
Python runtime not available (ENOENT) | error | The host has no Python interpreter. A failed dependency install shows PythonRunner failed: <message> instead. Both are host problems, not workflow problems. |
Input contract
-
contentstring Optional -
Raw HTML string.
-
content_base64string Optional -
file_pathstring Optional
Output contract
-
textstring Optional -
charsnumber Optional -
emptyboolean Optional -
methodstring Optional -
metadataobject Optional
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "ai.html.extract.text",
"name": "HTML Text Extraction",
"category": "ai",
"version": "1.0.0",
"description": "Extracts the main readable content from HTML or XHTML documents using trafilatura with content-boundary detection.\n\n Strips navigation chrome, scripts, style blocks, advertising containers, cookie banners, headers, footers, and comment threads while preserving the substantive article body.\n\n **Features:**\n - **Boilerplate removal:** Detects and removes page chrome based on trafilatura's trained extractors, tuned for modern CMS and blog layouts.\n - **Structural preservation:** Retains headings, paragraphs, ordered and unordered lists, and blockquotes in document order.\n - **Precision/recall tradeoff:** `favor_precision` toggles between aggressive cleanup (default, fewer false positives) and permissive extraction (recovers content on unconventional layouts).\n - **Metadata extraction:** Pulls title, canonical URL, author, publish date, site name, and language when surfaced by the page's meta tags, Open Graph, or JSON-LD.\n - **Inputs:** Accepts raw HTML as a string, base64-encoded HTML, or a local file path.",
"capabilities": [
"html",
"xhtml",
"markup",
"text-extraction"
],
"config_schema": {
"type": "object",
"properties": {
"favor_precision": {
"type": "boolean",
"title": "Favor Precision",
"default": true,
"description": "Trade recall for precision. Turn off if content is getting truncated."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "Raw HTML string."
},
"content_base64": {
"type": "string"
},
"file_path": {
"type": "string"
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"metadata": {
"type": "object"
}
}
},
"ports": [
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"tags": [
"ai",
"html",
"text",
"markup"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"favor_precision": {
"type": "boolean",
"title": "Favor Precision",
"default": true,
"description": "Trade recall for precision. Turn off if content is getting truncated."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "Raw HTML string."
},
"content_base64": {
"type": "string"
},
"file_path": {
"type": "string"
}
}
}{
"type": "object",
"properties": {
"text": {
"type": "string"
},
"chars": {
"type": "number"
},
"empty": {
"type": "boolean"
},
"method": {
"type": "string"
},
"metadata": {
"type": "object"
}
}
}[
{
"port_id": "extracted",
"label": "Extracted",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
htmlxhtmlmarkuptext-extraction- Tags
aihtmltextmarkup
Notes and limits
- Runs a Python script in a child process. The first run on a worker host creates a virtual environment and installs the script's pinned dependencies (it can take minutes and is not counted in the node timeout); later runs reuse it.
file_pathmust point to a file on the local disk of the orchestrator host that runs the node; it is not a URL and is not fetched from storage.- The script is killed after
execution.timeout_ms; when that key is not set the code uses 60000 ms, not the schema default of 300000. - The node does not fetch URLs; give it HTML that an upstream node already downloaded.
Reviewed against the orchestrator code · 31e874b · 2026-11-26