Runtime exports are grouped by purpose; TypeScript declarations shipped with the package remain the exact source of truth.
parse(input, options?)parses already-decoded text and returns aParsedDocument.parseBytes(input, options?)sniffs/decodes bytes and returns aParsedDocument.parseStream(stream, options?)reads, decodes, and parses a byte stream.parseFragment(input, context, options?)parses with an explicit namespace-awareHtmlFragmentContextInputand returns aParsedFragment.serialize(input, options?)serializes a document, fragment, or complete node representation.SerializeOptions.scriptingModecontrols the conditionalnoscriptrule. A document or fragment inherits the mode retained from parsing; an individual node defaults to"inert".tokenizeByteStreamEager(stream, options?)returns aTokenizeByteStreamEagerResultcontaining logical tokens plus encoding and resource evidence after EOF. Its budgets include deterministicmaxSteps.getParseErrorSpecRef(parseErrorId)maps a named parser diagnostic to its dedicated HTML Standard anchor and other identifiers to the general parse-errors section.
walk(tree, visitor, options?)visits every node.walkElements(tree, visitor, options?)visits elements only.findById(tree, id, options?)finds a parser node id.findAllByTagName(tree, tagName, options?)matches HTML tag names.findAllByTagNameNS(tree, namespaceUri, localName, options?)matches an exact expanded element name.findAllByAttr(tree, name, value?, options?)matches unnamespaced HTML attributes.findAllByAttrNS(tree, namespaceUri, localName, value?, options?)matches an exact expanded attribute name.getAttributeValue(node, name)andhasAttribute(node, name)inspect unnamespaced HTML attributes.getAttributeValueNS(node, namespaceUri, localName)andhasAttributeNS(node, namespaceUri, localName)inspect exact expanded names.
The namespace constants are HTML_NAMESPACE_URI, SVG_NAMESPACE_URI,
MATHML_NAMESPACE_URI, XLINK_NAMESPACE_URI, XML_NAMESPACE_URI, and
XMLNS_NAMESPACE_URI.
extractText(input, options)returns a boundedTextExtractionResult.iterateText(input, options)yields bounded tokens with provenance.outline(tree, options?)builds heading and section entries.chunk(tree, options?)groups structural text by configured limits.computePatch(document, edits)validates edits and creates a source-bound patch plan.applyPatchPlan(document, plan)applies a plan to its originating document.
The policy constants are VISIBLE_TEXT_HTML_POLICY and TEXT_CONTENT_POLICY.
Operational classes are HtmlBudgetExceededError, HtmlConfigurationError,
HtmlPatchPlanningError, HtmlStreamReadError, and HtmlAbortError.
Prefer the structural guards isHtmlBudgetExceededError,
isHtmlConfigurationError, isHtmlPatchPlanningError,
isHtmlStreamReadError, isHtmlAbortError, and isHtmlOperationalError when
the value can cross realms or package boundaries.
Key exported type groups include:
- parsing and operations:
ParseBudgetOptions,ParseOptions,ParseBytesOptions,ParseFragmentOptions,HtmlFragmentContextInput,HtmlFragmentContext,HtmlFragmentContextAttribute,HtmlDocumentMode,HtmlElementNamespaceUri,HtmlAttributeNamespaceUri,ParseStreamBudgetOptions,ParseStreamOptions,TokenizeByteStreamEagerBudgetOptions,TokenizeByteStreamEagerOptions,SerializeOptions,HtmlScriptingMode,OperationOptions,SourceRetention; - trees and metadata:
ParsedDocument,ParsedFragment,ParseMetadata,ParseEncodingMetadata,ParseResourceUsage,DocumentTree,FragmentTree,HtmlNode,NodeKind,ElementNode,SerializableNode,TemplateContentNode,TextNode,CommentNode,ProcessingInstructionNode,DoctypeNode,DoctypeExternalId,Attribute,Span,SpanProvenance,ParseError,NodeId,NodeVisitor, andElementVisitor; - traces and tokens:
TraceMode,TraceEvent,TraceEventCallback,TraceResult,TraceSummary,TraceSummaryResult,TraceEventsResult,TraceBudgetEvent,TraceDecodeEvent,TraceInsertionModeTransitionEvent,TraceParseErrorEvent,TraceStreamEvent,TraceTokenEvent,TraceTreeMutationEvent,Token,TokenAttribute,StartTagToken,EndTagToken,CharsToken,CommentToken,ProcessingInstructionToken,DoctypeToken,EofToken,TokenizationResourceUsage,TokenizeByteStreamEagerMetadata, andTokenizeByteStreamEagerResult; - extraction:
TextExtractionPolicy,TextExtractionOptions,TextExtractionOptionsBase,VisibleTextExtractionOptions,TextContentExtractionOptions,TextExtractionResult,TextExtractionToken,TextExtractionTokenKind,TextExtractionSourceNodeKind,TextExtractionSourceRole, andTextProvenanceRange; - structural output:
Outline,OutlineEntry,Chunk,ChunkOptions,Edit,RemoveNodeEdit,ReplaceTextEdit,SetAttrEdit,RemoveAttrEdit,InsertHtmlBeforeEdit,InsertHtmlAfterEdit,PatchPlan,PatchStep,PatchSliceStep, andPatchInsertStep; - failures:
HtmlOperationalError,HtmlBudgetName,HtmlConfigurationErrorReason, andHtmlPatchPlanningReason.
See limits, errors, and safety for option semantics and the data model for structural invariants.
The npm/Node and JSR entrypoints expose the same runtime values and the same
canonical TypeScript types. There are no JSR-only declarations, renamed budget
aliases, or wrapper signatures. Import the names documented above from either
@ismail-elkorchi/html-parser or jsr:@ismail-elkorchi/html-parser.