Registry / serialization / html
library1.16jsnpmunverified

The `html` package, currently at version 1.0.0, functions as a command-line utility for pretty-printing HTML code. It is a direct Node.js port of `beautify-html.js`, which itself is based on `jsbeautifier`. The tool is designed primarily for CLI usage, accepting HTML input via `stdin`, file arguments, or interacting with the system clipboard through utilities like `pbpaste` and `pbcopy` on macOS. Its core purpose is to take minified or unformatted HTML and output a human-readable, indented version. Given its last update in 2012, the project is abandoned. Its release cadence is non-existent, and users are instructed to manually update its underlying `jsbeautifier` dependency, indicating a lack of active maintenance and potential compatibility issues with modern JavaScript environments or Node.js versions. There are no notable differentiators over modern HTML formatters beyond its extremely simple, direct CLI piping approach, which is now largely obsolete.

npm install html
INSTALL
IMPORT
SIG · HTML
H
html
serializationjavascriptv1.16
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

html CLI
npx html
import html from 'html'
The primary use case is as a CLI tool; programmatic import is for CommonJS only.
prettyPrint (CommonJS)
const { prettyPrint } = require('html');
import { prettyPrint } from 'html';
This package is an old CommonJS module and does not support ES modules natively. It also does not ship with TypeScript types.

Demonstrates how to use the `html` CLI tool to pretty-print a string of ugly HTML passed via stdin.

import { exec } from 'node:child_process'; const uglyHtml = '<h2><strong><a href="http://awesome.com">AwesomeCom</a></strong><span>is awesome</span></h2>'; exec(`echo "${uglyHtml}" | npx html`, (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`); return; } if (stderr) { console.error(`stderr: ${stderr}`); } console.log('Pretty Printed HTML:\n', stdout); // Expected output will be formatted HTML like: // <h2> // <strong> // <a href=http://awesome.com>AwesomeCom</a> // </strong> // <span> // is awesome // </span> // </h2> });
html --version
Debug
Known issues
breakingThis package is an abandoned CommonJS module from 2012 and is not compatible with modern ES module environments without specific loader configurations or transpilation. Attempting to `import` it will likely result in errors.
fix
For new projects, use a modern HTML beautifier like Prettier or `js-beautify` directly. If absolutely necessary, configure Node.js to load CJS modules in an ESM context, or use `require()` if in a CJS file.
affects: >=1.0.0
deprecatedThe project is explicitly abandoned. The README instructs users to manually update its core `beautify-html.js` dependency by dropping new files into the `lib/` directory, rather than receiving updates via npm. This means the version of the underlying beautifier logic is extremely outdated and will not receive security patches or improvements.
fix
Avoid using this package. Migrate to actively maintained alternatives such as `prettier` for comprehensive code formatting, or a modern `js-beautify` version if a direct replacement is needed.
affects: >=1.0.0
gotchaThe package does not ship with TypeScript type definitions. Using it in a TypeScript project would require manually declaring types or ignoring type errors.
fix
If programmatic use is unavoidable in TypeScript, create a declaration file (`html.d.ts`) with `declare module 'html' { export function prettyPrint(html: string, options?: any): string; }` or use `@ts-ignore`.
affects: >=1.0.0
Errors
Common errors & fixes
html: command not found
The `html` CLI tool was not installed globally or is not in the system's PATH, or `npx` was not used.
fix
Install the package globally: `npm install -g html` or run it via `npx html` to execute without global installation.
TypeError: require is not a function
Attempting to use `require('html')` in an ES module context (`type: "module"` in `package.json` or `.mjs` file).
fix
If programmatic use is desired, use a modern HTML formatter that supports ESM. If forced to use this package, you must use it in a CommonJS file or configure an ES module loader to interoperate with CJS modules.
Error: Cannot find module 'html'
The package was not installed in the current project or is not correctly resolved by Node.js.
fix
Run `npm install html` in your project directory.
Upgrade
Version history
1.16latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
html — npm install html · libregistry