npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

strip-inline-styles

v1.0.0

Published

A lightweight utility to remove inline styles from HTML strings, with no dependencies

Readme

strip-inline-styles

A lightweight utility to remove inline styles from HTML strings, with no dependencies. Perfect for Angular, React, Vue, and Node.js applications.

npm version GitHub

Repository

GitHub Repository

Features

  • 🎯 Removes all inline styles from HTML strings
  • 🔧 Option to remove specific styles while preserving others
  • 🌳 Handles nested and complex HTML structures
  • 🛡️ TypeScript support with full type definitions
  • ⚡ Zero dependencies
  • 🧪 Comprehensive test coverage
  • 🌐 Works in any JavaScript environment

Installation

npm install strip-inline-styles

Usage

Basic Usage

import { stripInlineStyles } from "strip-inline-styles";

const html = '<p style="color: red; font-size: 16px;">Hello</p>';
const result = stripInlineStyles(html);
console.log(result);
// Output: <p>Hello</p>

Framework-specific Usage

React

import { stripInlineStyles } from 'strip-inline-styles';

function MyComponent() {
  const htmlContent = '<div style="color: red;">Hello React!</div>';
  const cleanHtml = stripInlineStyles(htmlContent);

  return <div dangerouslySetInnerHTML={{ __html: cleanHtml }} />;
}

Angular

import { Component } from "@angular/core";
import { stripInlineStyles } from "strip-inline-styles";

@Component({
  selector: "app-my-component",
  template: ` <div [innerHTML]="cleanHtml"></div> `,
})
export class MyComponent {
  htmlContent = '<div style="color: red;">Hello Angular!</div>';
  cleanHtml = stripInlineStyles(this.htmlContent);
}

Vue

<template>
  <div v-html="cleanHtml"></div>
</template>

<script>
import { stripInlineStyles } from "strip-inline-styles";

export default {
  data() {
    return {
      htmlContent: '<div style="color: red;">Hello Vue!</div>',
    };
  },
  computed: {
    cleanHtml() {
      return stripInlineStyles(this.htmlContent);
    },
  },
};
</script>

Node.js

import { stripInlineStyles } from "strip-inline-styles";

const html = '<p style="color: red;">Hello Node.js!</p>';
const result = stripInlineStyles(html);
console.log(result);
// Output: <p>Hello Node.js!</p>

Remove Specific Styles

import { stripInlineStyles } from "strip-inline-styles";

const html = '<p style="color: red; font-size: 16px; margin: 10px;">Hello</p>';
const result = stripInlineStyles(html, {
  removeSpecificStyles: ["color", "font-size"],
});
console.log(result);
// Output: <p style="margin: 10px;">Hello</p>

Handle Complex HTML

import { stripInlineStyles } from "strip-inline-styles";

const html = `
  <div style="padding: 20px;">
    <header style="background: #f0f0f0;">
      <h1 style="color: blue;">Title</h1>
    </header>
    <main>
      <section style="margin: 10px;">
        <p style="font-size: 14px;">Content</p>
      </section>
    </main>
  </div>
`;

const result = stripInlineStyles(html);
console.log(result);
// Output: Clean HTML with all inline styles removed

API

stripInlineStyles(html: string, options?: Options): string

Parameters

  • html (string): The HTML string to process
  • options (object, optional): Configuration options
    • removeSpecificStyles (string[], optional): Array of specific style properties to remove
    • preserveClasses (boolean, optional): Whether to preserve class attributes (default: true)

Returns

  • (string): The processed HTML with inline styles removed

Browser Support

The library works in all modern browsers and Node.js environments. No dependencies required.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request to the GitHub repository.

License

MIT License - feel free to use this project in any way you want.

Author

Nati Grossman

Support

If you find this package helpful, please consider giving it a star on GitHub!