New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

html2css-map

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html2css-map

Extract inline styles into reusable CSS classes

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
2
-75%
Maintainers
1
Weekly downloads
 
Created
Source

html2css-map

GitHub package.json version GitHub Actions Workflow Status GitHub License

NPM Downloads

html2css-map is a command-line tool that extracts inline styles from HTML files, converts them into reusable CSS classes, and rewrites the HTML with cleaner, class-based markup.

Features

  • Scans .html files for inline styles
  • Generates a css file with reusable classes
  • Replaces inline styles with class="" attributes
  • Deduplicates identical styles
  • Dry-run mode to preview changes
  • Optional JSON changelog log

Installation

You can install html2css-map as an npm package globally or as a devDependency:

Global Installation

npm install -g html2css-map
npm install --save-dev html2css-map

Usage

After installation, you can run the tool via npm scripts or directly through the command line.

Add the following script to your package.json:

{
  "scripts": {
    "html2css": "html2css-map --input ./src --output ./custom.css"
  }
}

Run the script:

npm run html2css

This will:

  • Scan the ./src folder (change to your current directory)
  • Generate a custom.css file (change to your preferred name)

Example

Before:

<div style="color: red; font-size: 18px;">Hello</div>

After:

<div class="html2css-style-1">Hello</div>

custom.css:

.html2css-style-1 {
  color: red;
  font-size: 18px;
}

Compatibility

  • Works with Angular templates (.html files). However, it does not support Angular’s ngStyle directive.
  • Works with standard .html files, extracting inline styles and converting them into reusable CSS classes.

CLI Options

OptionDescription
--input, -i(Required) Path to the folder containing .html files to scan.
--output, -o(Required) Path to the output CSS file to generate.
--dry(Optional) If set, it will preview changes without modifying any files.
--log(Optional) Path to generate a JSON changelog file that tracks changes made.

Contributing

Contributions are welcome! If you encounter issues or have ideas to enhance the library, feel free to submit an issue or pull request.

Keywords

inline-styles

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts