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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jasonmarq/html-2-javascript

v1.0.3

Published

A simple way to create a JS object from any DOM element

Readme

HTML to Markdown Converter

This is a utility module that allows you to convert HTML elements into a JavaScript Object representation with Markdown-like structure.

Installation

No installation is required for this module. Simply include the code in your project and start using it.

Usage

To use the createMarkdownForElement function to create a JavaScript Object representation of an HTML element, follow these steps:

  1. Select the HTML element you want to copy:
const page = document.querySelector("html");
  1. Call the createMarkdownForElement function, passing the HTML element's tag name and the element itself as parameters:
const markdown = createMarkdownForElement(page.tagName.toLowerCase(), page);
  1. Optional: If you want to download the resulting JavaScript Object as a JSON file, use the following code:
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(markdown));
const downloadAnchorNode = document.createElement("a");
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", "markdown.json");
document.body.appendChild(downloadAnchorNode); // Required for Firefox
downloadAnchorNode.click();
downloadAnchorNode.remove();

This code creates a download link for the generated JavaScript Object in JSON format. When clicked, it triggers the download of the JSON file named "markdown.json".

Make sure to adjust the code according to your specific requirements, such as selecting the desired HTML element and providing the appropriate file name for the download.

##Note The resulting JavaScript Object representation of the HTML element will have a structure that resembles Markdown. It includes the element's tag name, attributes, and child elements, recursively for nested elements.

This module relies on the functions componentIdGenerator, createElement, createText, and hasTextChild to generate unique component IDs, create element objects, handle text content, and check if an element has text children, respectively. Ensure that these functions are available and accessible within your project.

Please be aware of the cross-browser compatibility when using the download functionality, as the code provided may require adjustments for specific browsers.