Registry / developer tools / html-formatter

html-formatter

JSON →
library0.1.9jsnpmunverified

A minimal HTML prettifier that formats HTML strings with proper indentation. Current stable version is 0.1.9, last updated in 2018, with no recent releases or maintenance activity. It uses a single `render()` function to beautify ugly HTML. Compared to alternatives like `prettier` or `js-beautify`, this package is far less feature-rich and has not been updated in years. It only supports CommonJS and does not ship TypeScript types. Not recommended for new projects.

npm install html-formatter
INSTALL
IMPORT
SIG · HTML-FORMATTER
H
html-formatter
developer toolsjavascriptv0.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
const formatter = require('html-formatter')
import formatter from 'html-formatter'
Package only supports CommonJS; ESM import will fail.
render
const formatter = require('html-formatter'); formatter.render(html)
const { render } = require('html-formatter'); render(html)
Module exports a single function directly, not as a named export.
type
No TypeScript types available; use @ts-ignore or declare module.
Package does not include type definitions.

Demonstrates formatting a simple HTML string using the render() function.

const formatter = require('html-formatter'); const uglyHtml = '<div><p>Hello</p></div>'; const prettyHtml = formatter.render(uglyHtml); console.log(prettyHtml); // Output: // <div> // <p>Hello</p> // </div>
Debug
Known issues
deprecatedPackage has not been updated since 2018; no support for modern HTML5 features or syntax.
fix
Use an actively maintained formatter like prettier or js-beautify.
affects: >=0.1.0
gotchaPackage uses regex-based parsing; may produce incorrect output for complex HTML or non-standard syntax.
fix
Consider a parser-based formatter (e.g., prettier) for robust results.
affects: >=0.1.0
gotchaOnly CommonJS import works; ESM import (import) will throw an error.
fix
Use require() or switch to an ESM-compatible formatter.
affects: >=0.1.0
gotchaIndentation is fixed to 2 spaces; no configuration options available.
fix
Use a configurable formatter like prettier.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'html-formatter'
Package not installed.
fix
Run 'npm install html-formatter'
formatter.render is not a function
Incorrect import: destructured { render } instead of importing the whole module.
fix
Use 'const formatter = require('html-formatter')' then 'formatter.render(html)'
Unexpected token 'export'
Trying to use ESM import syntax on a CommonJS-only package.
fix
Use 'require' instead of 'import'.
Upgrade
Version history
0.1.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
html-formatter — npm install html-formatter · libregistry