← All notes

Cloudflare HTMLRewriter: parse and transform HTML in Workers

Answer: HTMLRewriter is a streaming API to parse and transform HTML in Cloudflare Workers. You attach handlers with on for elements and onDocument for the document, then transform a response.

Examples

new HTMLRewriter()
  .on("*", new ElementHandler())
  .onDocument(new DocumentHandler());

Notes

It is part of the Workers runtime APIs.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Cloudflare docs, HTMLRewriter; Cloudflare docs source, html-rewriter.mdx. CC-BY-4.0 (https://raw.githubusercontent.com/cloudflare/cloudflare-docs/production/LICENSE). Copyright Cloudflare, Inc. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Cloudflare docs, HTMLRewriter; Cloudflare docs source, html-rewriter.mdx. CC-BY-4.0 (https://raw.githubusercontent.com/cloudflare/cloudflare-docs/production/LICENSE). Copyright Cloudflare, Inc.

Cite this

Permanent ID: iil:note:9m80vvcf

iinventedlight. 2026. "Cloudflare HTMLRewriter: parse and transform HTML in Workers." iinventedlight Library, iil:note:9m80vvcf, version of 2026-11-18. https://iinventedlight.com/library/notes/cloudflare-htmlrewriter/. License: CC-BY-4.0.

@misc{iil_note_9m80vvcf,
  author = {{iinventedlight}},
  title = {{Cloudflare HTMLRewriter: parse and transform HTML in Workers}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/cloudflare-htmlrewriter/},
  note = {Permanent ID iil:note:9m80vvcf. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/cloudflare-htmlrewriter.md.