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
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.
Works with
Packages commonly used together with html: ones it builds on, ones built on it, and its own family.
- source_spanhtml depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- csslibhtml depends on itA Dart library that parses CSS strings or byte lists into an AST.
- analyzerSame familyPerforms static analysis of Dart code for tool integration and embedding.
- yamlSame familyA Dart library for parsing YAML documents into Dart data structures.
- dart_styleSame familyProvides an API and CLI to format Dart source code automatically.
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- source_mapsSame familyA Dart library to parse, build, and manipulate source map v3 files.
- string_scannerSame familyA class for parsing strings using a sequence of patterns.