html-format
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

html-format

Format HTML strings by indenting, wrapping, and removing unnecessary whitespace while preserving newlines.

Install

npm install html-format

Usage

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>
`;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.73,580latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.73,580
1.1.6153
1.1.53
1.1.41
1.1.31
1.1.23,187
1.1.10
1.1.00
1.0.2460
1.0.1747
1.0.00
0.0.1-security1

Package Sidebar

Install

npm i html-format

Weekly Downloads

8,133

Version

1.1.7

License

MIT

Unpacked Size

9.33 kB

Total Files

5

Last publish

Collaborators

  • mohd-akram