Skip to content
pubscout

html

0.15.7, released 3 months ago by tools.dart.dev

A Dart implementation of an HTML5 parser for strings and bytes.

WASM-ready
$ flutter pub add html
Source repository

What it does

Provides APIs for parsing and manipulating HTML content outside the browser. It parses HTML strings or byte lists into a document object model and supports document fragments and low-level tokenization control.

AI-written summary of version 0.15.7, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to parse HTML content inside a Dart backend or command-line tool
  • You want to manipulate or query HTML elements outside of a browser environment

Skip it when

  • You are working entirely within a Flutter UI and can use built-in web views
  • You only need to parse simple XML documents where an XML parser would suffice

Strengths

  • Fully-featured HTML5 parser ported from Python's html5lib
  • Supports parsing document fragments as well as full documents

Weaknesses

  • Dropped support for encodings other than UTF-8 and ASCII

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2
import 'package:html/parser.dart';

void main() {
  var document = parse(
      '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!');
  print(document.outerHtml);
}

Alternatives

Packages that do the same job and could replace html.

  • xml

    Pick xml if you are parsing strict XML documents rather than HTML5.

Works with

Packages commonly used together with html: ones it builds on, ones built on it, and its own family.