HTML Pretty Printer CLI

1.0.0 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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>
});

view raw JSON →