Skip to Content
PureHTMLdocs

Introduction

A declarative, schema-driven specification for HTML data extraction.

What is PureHTML?

PureHTML is a cross-language specification designed to extract structured JSON data from arbitrary HTML documents.

Instead of writing brittle, imperative scraper code filled with DOM queries, regexes, and manual string manipulations, PureHTML lets you define your extraction rules declaratively using YAML or JSON.

title:
  selector: h1
  transform: trim

price:
  selector: .price
  transform: [trim, number]

inStock:
  selector: .stock-status
  transform: exists

Why PureHTML?

  • Language Independent: PureHTML is a unified specification implemented natively across TypeScript/JavaScript, Go, Python, Java, and Ruby. Write rules once, evaluate them in any backend or environment.
  • Resilient to Markup Changes: Websites change layout and classes constantly. PureHTML supports fallback selector chains, union patterns, and default values to prevent scrapers from breaking when pages undergo A/B testing or redesigns.
  • Clean Transformation Pipelines: Chain built-in transformers such as trim, number, attr, resolve, jsonpath, and regex directly on extracted values.
  • Strictly Typed & Schema-Backed: A complete JSON schema and TypeScript types validate your rules at authoring time.

Quick Example

Here is a quick demonstration of extracting data from a product listing:

properties:
title:
  selector: .title
  transform: trim
price:
  selector: .price
  transform:
    - 'replace("\$", "")'
    - trim
    - number
inStock:
  selector: .badge
  transform: exists
checkoutUrl:
  selector: a.buy
  transform:
    - attr(href)
    - resolve

Next Steps

On this page