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

html-to-gutenberg

v4.2.8

Published

Transform any valid HTML string into fully editable WP Gutenberg blocks in seconds rather than hours.

Downloads

728

Readme

HTML to Gutenberg Converter

Convert HTML strings to valid, editable WordPress Gutenberg blocks in seconds instead of hours. With this script, you can create and build valid Gutenberg blocks that feature editable text, forms, inline and background images, as well as SVGs. It includes support for TailwindCSS.

Features

  • 🪄 Instantly transforms static HTML into Gutenberg blocks Saves hours of manual work by automating block creation from any valid HTML snippet.

  • 🔌 Generates a complete, installable WordPress block plugin Outputs all necessary plugin files (JS, CSS, PHP) so you can drop them into WordPress immediately.

  • 🎨 Keeps your design intact Automatically extracts and preserves CSS from the original HTML into a separate style.css.

  • 🧩 Modular and scalable Separates assets (JS, CSS, components) into clean files, making it easy to maintain and extend.

  • 📦 Seamlessly integrates with dynamic block systems Works perfectly for headless or custom Gutenberg setups where blocks are registered via JS, not PHP.

  • 🚀 Speeds up prototyping Ideal for quickly testing block ideas or converting landing pages and templates into WordPress blocks.

  • 🧠 Works with your file system or plugin builder logic Since it returns all files as either strings or source files, you can save them however you like (via PHP, APIs, etc.).

  • 🧰 Built for automation and customization Can be embedded in custom tools, UIs, or pipelines to generate Gutenberg blocks on demand.

Installation

Install html-to-gutenberg with npm:


npm  install  html-to-gutenberg

Usage/Examples


// block-generator.js

import  block  from  'html-to-gutenberg';

const  htmlString = '<div>My content</div>';

{
	const files = await  block(htmlString, { name:  'My Block' });
	console.log(files);
}

When provided with a valid HTML string and the required options, the block function will generate the necessary WordPress block files with the specified configuration. To install the block and its assets, simply load the generated folder into the plugins folder and activate it.

Example

Working demo

Options object reference

| Option | Description | Type | Required? | Default | |---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-----------------------------------------------------------------------------------------------------|-------------------| | name | The name of your block. This will also be used for the folder name and internal references. | string | Yes | My block | | source | A URL where relative paths resolve. E.g., http://localhost/website. | string | Yes, only if the HTML string or the stylesheet has relative paths. | null | | prefix | A namespace prefix for the block name, typically aligned with your project (e.g., "wp" or "myplugins"). | string | No | wp | | category | The WordPress block category where the block appears in the editor. Use an existing one or register a custom category if needed. | string | No | common | | basePath | The absolute path where the output files and folders will be saved. | string | No | Current directory | | generateIconPreview | If true, generates a static image preview (JPEG) of the block's icon for display in the block picker. | boolean | No | false | | shouldSaveFiles | When true, the generated block files are saved directly to disk. When false, returns an object containing the file contents as strings instead. | boolean | No | true | | jsFiles | An array of external JavaScript file URLs to enqueue with the block on the editor and the frontend. Useful for adding remote libraries. | string[] | No | [] | | cssFiles | An array of external CSS file URLs to enqueue with the block on the editor and the frontend. Useful for adding additional remote stylesheets. | string[] | No | [] |

License

MIT