npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

d2m

v1.5.0

Published

Convert DOM to Semantic Markdown

Downloads

211

Readme

DOM to Markdown CLI

A command-line tool to convert HTML DOM to Semantic Markdown.

Installation

To use the CLI tool with npx or install it globally, follow these instructions:

Using npx

You can use the tool directly with npx without needing to install it globally:

npx d2m@latest -i tryme.html -o output.md

Global Installation

To install the CLI tool globally, use the following commands:

  1. Clone the repository:
git clone https://github.com/romansky/dom-to-semantic-markdown.git
cd examples/cli
  1. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Link the package globally:
npm link

After linking the package globally, you can use the d2m command anywhere on your system.

Usage

The d2m command converts HTML files or URL content to Markdown. Here are the available options:

  • -i, --input <file>: Input HTML file
  • -o, --output <file>: Output Markdown file (if not specified, the result will be printed to the console)
  • -e, --extract-main: Extract main content (optional)
  • -u, --url <url>: URL to fetch HTML content from
  • -t, --track-table-columns: Enable table column tracking for improved LLM data correlation
  • -m, --include-meta-data <"basic" | "extended">: Include metadata extracted from the HTML head
  • -p, --use-playwright: Use Playwright to fetch HTML from URL (handles dynamic content, may require npx playwright install if browsers are not found)
  • --playwright-wait-until <event>: Specify the Playwright page.goto waitUntil event. Options: load (default), domcontentloaded, networkidle, commit. Used only with -p or --use-playwright.

Explanation of waitUntil options:

  • 'domcontentloaded': Waits for the DOMContentLoaded event. The HTML document has been completely parsed, but stylesheets, images, and subframes may still be loading.
  • 'load': Waits for the load event. The entire page, including all dependent resources like stylesheets and images, has finished loading. This is the new default if -p is used.
  • 'networkidle': Waits until there are no network connections for at least 500 ms. This is excellent for pages that load data asynchronously or SPAs that render content after the initial load.
  • 'commit': Waits for the navigation to be committed. This is the fastest but might capture the page in a very early state, often before any meaningful content is rendered by JavaScript.

Note: If you plan to use the --use-playwright option (see Usage), you might need to install Playwright's browser drivers first:

npx playwright install

Examples

Using npx

(without local install use npx d2m@latest -i ... or d2m -i ... if globally installed, ie- npm link )

  1. Convert an HTML file and print the result to the console:
npx d2m@latest -i tryme.html
  1. Convert an HTML file and save the result to a Markdown file:
npx d2m@latest -i tryme.html -o output.md
  1. Extract the main content from the HTML file and print the result to the console:
npx d2m@latest -i tryme.html -e
  1. Convert HTML content from a URL and print the result to the console:
npx d2m@latest -u https://example.com
  1. Convert HTML content from a URL and save the result to a Markdown file:
npx d2m@latest -u https://example.com -o output.md
  1. Convert an HTML file with table column tracking:
npx d2m@latest -i tryme.html -t
  1. Convert HTML content from a URL using Playwright and save to a file:
npx d2m@latest -u https://example.com -p -o output_playwright.md
  1. Convert HTML content from a URL using Playwright while waiting until network has settled
npx d2m@latest -u https://example.com -p --playwright-wait-until networkidle -o output_spa.md

License

This project is licensed under the MIT License. See the LICENSE file for details.