Package selection guidance compiled from public package information, community data, and project usage.
A Flutter/Dart package that converts HTML content to Markdown format, supporting CommonMark standards, basic table rendering, and customizable conversion rules. It is ideal for applications needing to transform rich HTML text into clean, readable Markdown, such as in content editors, documentation tools, or blog platforms. The library is compatible across all major platforms including Android, iOS, Web, macOS, Windows, and Linux, making it versatile for cross-platform development. Its extensibility allows developers to define custom parsing logic for specific use cases.
Use cases
Converting HTML emails to Markdown
Rendering blog posts from HTML sources
Building content editors with Markdown output
Transforming user-generated HTML into structured Markdown
Key features
Supports CommonMark specification
Handles simple tables
Customizable conversion rules
Cross-platform compatibility
Lightweight and easy to integrate
Suitable for
Content management systems
Documentation generators
Markdown-based note-taking apps
Apps processing user-submitted HTML
Considerations
Limited support for complex HTML structures
Custom rules require additional implementation
May not preserve all HTML styling attributes
Not optimized for very large HTML documents
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
import'package:html2md/html2md.dart'as html2md;
import'package:flutter_markdown/flutter_markdown.dart';
build(BuildContext context) {
// Caution!// This is not best practice, you should not call convert in build// and the converted markdown should put in state.var html = '<h1>HTML2MD Demo</h1>';
var markdown = html2md.convert(html);
returnMarkdown(data: markdown);
}
Config
You can config convert style by passing styleOptions to convert, elements that should be ignored also can be set with ignore. If you want to customize element converting, use custom rules!
Want to customize element converting? Write your rules!
Rule fields explaination
finalString name; // unique rule namefinalList<String>? filters; // simple element name filters, e.g. ['aside']finalFilterFn? filterFn; // function for building complex element filter logicfinalReplacement? replacement; // function for doing the replacingfinalAppend? append; // function for appending content
Rule example - Convert the onebox section of discourse post to a link