Registry / devops / tinyhtml

tinyhtml

JSON →
library0.0.72jsnpmunverified

Tinyhtml is a compact, reliable, and customizable HTML minifier for Node.js. The current stable version is 0.0.72, released on npm. It focuses on removing unnecessary whitespace, collapsing attribute values, and optionally parsing script/style tags with custom parsers. Unlike other minifiers, it provides fine-grained control over tag content via parsers and allows preserving specific whitespace patterns. It is actively maintained, with a simple API and no dependencies. Suitable for build pipelines and server-side HTML compression.

npm install tinyhtml
INSTALL
IMPORT
SIG · TINYHTML
T
tinyhtml
devopsjavascriptv0.0.72
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.

tinyHTML
import tinyHTML from 'tinyhtml'
const tinyHTML = require('tinyhtml')
Package is ESM-only. CommonJS require() will fail with latest versions. Use import or dynamic import().
tinyHTML
const tinyHTML = require('tinyhtml').default || require('tinyhtml')
const tinyHTML = require('tinyhtml')
If using CommonJS, the default export is not directly available; use the workaround shown.
tinyHTML
import tinyHTML from 'tinyhtml'
import { tinyHTML } from 'tinyhtml'
Default export only; named import is incorrect.

Minifies an HTML string by removing unnecessary whitespace, collapsing attribute values, and stripping optional quotes.

import tinyHTML from 'tinyhtml'; const input = ` <body class="mediawiki ltr sitedir-ltr ns-4 ns-subject page-Wikipedia"> <div id="content" class="mw-body" role="main"> <h1 id="firstHeading">Wikipedia:Portada</h1> </div> </body> `; const result = tinyHTML(input); console.log(result); // <body class="mediawiki ltr sitedir-ltr ns-4 ns-subject page-Wikipedia"><div id="content" class="mw-body" role="main"><h1 id="firstHeading">Wikipedia:Portada</h1></div></body>
Debug
Known issues
breakingVersion 0.0.70+ switched to ESM-only. CommonJS require() will throw 'ERR_REQUIRE_ESM'.
fix
Use dynamic import() or upgrade to ES modules.
affects: >=0.0.70
deprecatedThe 'comments' option was deprecated in v0.0.60. Use 'parsers' to handle comments.
fix
Replace 'comments: true' with a custom parser for comments.
affects: >=0.0.60
gotchaBy default, tinyHTML removes all whitespace between tags, which may break inline script or style blocks.
fix
Use the 'parsers' option to preserve whitespace in script/style tags.
affects: *
gotchaBoolean attribute values are collapsed (e.g., disabled="disabled" becomes disabled).
fix
Use custom parsers if you need to preserve attribute values.
affects: *
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using CommonJS require() on an ESM-only package (>=0.0.70).
fix
Use dynamic import() or convert your project to ES modules.
Cannot find module 'tinyhtml'
Package not installed or installed as devDependency not included in production.
fix
Run 'npm install tinyhtml@latest --save' or 'npm install tinyhtml@latest --save-dev' if only needed in dev.
TypeError: tinyHTML is not a function
CommonJS require() returns an object with a default property in ESM packages.
fix
Use "tinyHTML = require('tinyhtml').default || require('tinyhtml')" or switch to import.
Upgrade
Version history
0.0.72latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
tinyhtml — npm install tinyhtml · libregistry