Registry / devops / htmlfy

htmlfy

JSON →
library1.0.1jsnpmunverified

An HTML formatter and minifier with a focus on simplicity and zero dependencies. Version 1.0.1 is the current stable release with no fixed release cadence. It provides both pretty-printing and minification for HTML strings, differentiating itself by its minimal footprint (no dependencies) and TypeScript support. Ideal for formatting or compressing HTML in Node.js or browser environments.

npm install htmlfy
INSTALL
IMPORT
SIG · HTMLFY
H
htmlfy
devopsjavascriptv1.0.1
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.

htmlfy
import { htmlfy } from 'htmlfy'
import htmlfy from 'htmlfy'
htmlfy is a named export, not default.
pretty
import { pretty } from 'htmlfy'
const pretty = require('htmlfy').pretty
Correct for ESM; for CJS use require('htmlfy').pretty.
minify
const { minify } = require('htmlfy')
const minify = require('htmlfy')
minify is a named export; destructure in CJS.

Demonstrates pretty-printing and minifying HTML with htmlfy.

import { pretty, minify } from 'htmlfy'; const ugly = '<div > < p >Hello</p></div>'; const beautified = pretty(ugly, { indent_size: 2 }); console.log(beautified); // Output: // <div> // <p>Hello</p> // </div> const minified = minify(beautified); console.log(minified); // Output: // <div><p>Hello</p></div>
Debug
Known issues
gotchaThe pretty function does not add newlines after void elements like <br> or <hr>.
fix
Use minify for consistent output or manually add newlines if needed.
affects: >=1.0.0
gotchaminify removes whitespace aggressively; it may break inline JavaScript or CSS if not careful.
fix
Ensure script and style content is properly handled or avoid minifying such sections.
affects: >=1.0.0
gotchaThe current version does not support formatting HTML with mixed content (e.g., text nodes with inline elements) beautifully.
fix
Consider alternatives like prettier for advanced formatting.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: htmlfy is not a function
Using default import instead of named import.
fix
Use import { htmlfy } from 'htmlfy'
Cannot find module 'htmlfy'
Package not installed or import path incorrect.
fix
Run npm install htmlfy and ensure the import path is correct.
TypeError: pretty(...).replace is not a function
Calling pretty on something that is not a string.
fix
Ensure the input to pretty() is a string.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

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