npm
npmjs.com › package › html-format
html-format - npm
import format from "html-format"; const html = `\ <body> <main class="grid"> </main> </body> `; // indent = 2 spaces (default), width = 80 characters (default) format(html) == `\ <body> <main class="grid"> </main> </body> `; // indent = 4 spaces, width = 80 characters (default) format(html, " ".repeat(4)) == `\ <body> <main class="grid"> </main> </body> `; // indent = 4 spaces, width = 20 characters format(html, " ".repeat(4), 20) == `\ <body> <main class="grid"> </main> </body> `;
» npm install html-format
Published May 20, 2024
Version 1.1.7
Author Mohamed Akram
Repository https://github.com/mohd-akram/html-format
npm
npmjs.com › search
html prettify - npm search
HTML prettifier with options to format HTML according to your own preferences.
npm
npmjs.com › package › html-prettify
html-prettify - npm
HTML markup formatter. Latest version: 1.0.7, last published: 4 years ago. Start using html-prettify in your project by running `npm i html-prettify`. There are 22 other projects in the npm registry using html-prettify.
» npm install html-prettify
Published May 29, 2022
Version 1.0.7
Author Dominik Michal
Repository https://github.com/Dmc0125/html-prettify
npm
npmjs.com › package › html-formatter
html-formatter - npm
var formatter = require('html-formatter'); var html = '<!doctype><html><head></head><body></body></html>'; console.log( formatter.render(html) );
» npm install html-formatter
Published Mar 27, 2018
Version 0.1.9
Author uznam8x, prisf, codenut, html, minify, prettify, beautify, html framework
Repository https://github.com/uznam8x/html-formatter
npm
npmjs.com › search
format html - npm search
A string manipulation toolbox, featuring a string formatter (inspired by sprintf), a variable inspector (output featuring ANSI colors and HTML) and various escape functions (shell argument, regexp, html, etc).
npm
npmjs.com › package › @cucumber › html-formatter
@cucumber/html-formatter - npm
HTML formatter for Cucumber. Latest version: 22.0.0, last published: a month ago. Start using @cucumber/html-formatter in your project by running `npm i @cucumber/html-formatter`. There are 19 other projects in the npm registry using @cucumber/html-formatter.
» npm install @cucumber/html-formatter
Published Oct 03, 2025
Version 22.0.0
Author Aslak Hellesøy
Repository https://github.com/cucumber/html-formatter
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
More than 19.4k dependent packages on npmSee them all
npm
npmjs.com › search
beautify HTML - npm search
Prettify, format, beautify HTML.
npm
npmjs.com › search
html beautifier - npm search
HTML Beautifier support for JSTransformers.
GitHub
github.com › alexmarucci › gformat-html
GitHub - alexmarucci/gformat-html: An humble HTML Formatter
This excludes indentation. ... # regular $ npm install gformat-html --global # when using proxy like sinopia/verdaccio $ npm install gformat-html --global --registry=https://registry.npmjs.org/
Author alexmarucci
npm
npmjs.com › package › js-beautify
js-beautify - npm
Directives are placed in comments inside the file. Directives are in the format /* beautify {name}:{value} */ in CSS and JavaScript. In HTML they are formatted as <!-- beautify {name}:{value} -->.
» npm install js-beautify
Published Feb 27, 2025
Version 1.15.4
Author Einar Lielmanis
Repository https://github.com/beautifier/js-beautify
Homepage https://beautifier.io/
Top answer 1 of 2
20
You found all the resources you need. That module does it for you.
var html = require("html");
var data = '<h2><strong><a href="http://awesome.com">AwesomeCom</a></strong><span>is awesome</span></h2>';
var prettyData = html.prettyPrint(data, {indent_size: 2});
process.stdout.write(prettyData)
Look at it's source.
Or you could use child_process to execute the command found in the README: html *.html.
2 of 2
1
If you are looking for alternatives (perhaps because a project has been abandoned, or you don't like the API), you can use NPM's website to search for others. Here are a few options: https://www.npmjs.com/search?q=html%20prettify I sorted by popularity and picked the first one, pretty.
The code ends up looking pretty similar to the accepted answer:
import pretty from 'pretty';
var data = '<h2><strong><a href="http://awesome.com">AwesomeCom</a></strong><span>is awesome</span></h2>';
var prettyData = pretty(data);
process.stdout.write(prettyData)
npm
npmjs.com › package › gulp-format-html
gulp-format-html - npm
Security Update: npm classic token creation is now disabled. Existing classic tokens will be revoked on November 19, 2025. Migrate to trusted publishing or granular access tokens to avoid disruption. Learn more.× ... const gulp = require('gulp') const formatHTML = require('gulp-format-html') // or // const { formatHTML } = require(`gulp-format-html`) function views() { return gulp.src('views/**/*.html').pipe(formatHTML()).pipe(gulp.dest('dist')) } exports.dev = gulp.series(views)
» npm install gulp-format-html
npm
npmjs.com › package › html-to-formatted-text
html-to-formatted-text - npm
Latest version: 2.7.0, last published: 7 years ago. Start using html-to-formatted-text in your project by running `npm i html-to-formatted-text`. There are 7 other projects in the npm registry using html-to-formatted-text.
» npm install html-to-formatted-text
Published May 29, 2019
Version 2.7.0
Author Luke Scott
npm
npmjs.com › package › @mkhalidkhan › standard-html-formatter
@mkhalidkhan/standard-html-formatter - npm
const formatHTML = require("@mkhalidkhan/standard-html-formatter"); let data = `<html> <p> this is just a paragraph </p><p>This is just another paragraph</p> <html>`; formatHTML(2,data); // This will give you formatting based on 2 spaces.
» npm install @mkhalidkhan/standard-html-formatter
Published Nov 05, 2022
Version 0.0.4
Author Khalid Khan
npm
npmjs.com › search
html indent - npm search
Prettier is an opinionated code formatter · dustyo-o• 3.3.2 • a month ago • 0 dependents • MITpublished version 3.3.2, a month ago0 dependents licensed under $MIT · 752 · Format HTML strings. html · format · mohd-akram• 1.1.7 • a year ago • 43 dependents • MITpublished version 1.1.7, a year ago43 dependents licensed under $MIT ·
npm
npmjs.com › package › html-formatting
html-formatting - npm
A lightweight and dependency-free utility for sanitizing HTML markup according to custom rules. Key features include: ... Simple yet powerful rule configuration. ... node: A DOM element whose children will be formatted according to the specified ...
» npm install html-formatting
Published Mar 06, 2024
Version 2.0.0
Author Konstantin Basharkevich
Repository https://github.com/WEACOMRU/sanitize-html
npm
npmjs.com › search
html-formatter - npm search
🌹 Beautiful ESLint HTML formatter extended from ESLint's official HTML formatter by JulianLaval combined with Stylish by Sindre Sorhus
Npm
npm.io › search › keyword:beautify
Beautify | npm.io
HTML prettifier with options to format HTML according to your own preferences.
Npm
npm.io › package › gformat-html-formatter
Gformat-html-formatter NPM | npm.io
When the data-property ignore is true the node is skipped for formatting. The implementation is a derivated from rehype-format Version 2.3.0 rehype-format. ... @starptech/expression-parser@starptech/rehype-minify-whitespace@starptech/rehype-webparser@starptech/webparsergformat-hast-to-htmlhast-util-is-elementhast-util-to-stringhtml-void-elementshtml-whitespace-sensitive-tag-namesis-hiddenprettierrepeat-stringto-vfileunifiedunist-util-findunist-util-isunist-util-visit-parentsxtend