Updated Sep 21, 2026

Utilities

Select HTML elements and attributes with htmlq

jq-style extraction for HTML, driven by CSS selectors.

Agent

overview

What htmlq does

Connect an HTML file and enter a CSS selector such as h1, article a, or meta[name=description]. htmlq writes every matching element to the node's output file.

-t returns text content instead of serialized markup. -a returns one attribute from each selected element, which is useful for links, image sources, and metadata values. The input file is passed with -f.

htmlq parses HTML already present in the workflow. It does not fetch a URL or execute JavaScript. Use browser-fetch or Playwright first when the source still needs to be downloaded or rendered.

source github.com/mgdm/htmlq

use cases

Where htmlq fits

Extract article text

Select a heading or content container and enable -t for plain text.

Collect links

Select anchor elements and set -a to href.

Read metadata

Select a meta element and return its content attribute.

reference

htmlq inputs and flags

4 inputs
NameTypeFlagDescription
selectorSTRING--selectorCSS selector to match.
inputFILE--inputHTML input file.
textBOOLEAN--textWrite text content instead of HTML.
attributeSTRING--attributeWrite one selected attribute value.

Showing key inputs. htmlq exposes 4 inputs in total.

example

Run htmlq

htmlq · command
htmlq -t -f input.html 'h1'
sample output
Alpha

guidance

Choosing htmlq

Use htmlq when an HTML file is already available and a CSS selector identifies the needed content. Use browser-fetch or Playwright when the page still needs retrieval or rendering.

browser-fetch

Fetches pages and saves their HTML before selection.

trafilatura

Extracts main article text without requiring a CSS selector.

jq

Filters JSON rather than HTML.

faq

htmlq questions

No. Connect an HTML file produced by another node or uploaded as input.

Run htmlq yourself

A small HTML fixture feeds htmlq with selector h1 and -t, returning the heading text.

Facts on this page come from the live Trickest tool library.