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

html-fiddle

v1.0.5

Published

Middleware (connect) for modifying response html, useful with http-proxy

Readme

html-fiddle Build Status Coverage Status Semantic Versioning

html-fiddle is a connect middleware for modifying response html. It can be useful with http-proxy to modify HTML returned from the remote target.

Getting Started

Installation

$ npm i --save html-fiddle

Basic Usage

Use as connect middleware in your server. Provide a through function which returns a transform stream for HTML.

const fiddle = require('html-fiddle');
const replaceStream = require('replacestream');

app.use(fiddle({
    through: () => replaceStream('Original', 'Replaced')
}));

Above example uses replacestream library to create a stream which will transform the HTML. This will cause all text matching "Original" to be replaced with "Replaced".

Given: <html><body>Original!</body></html> Result: <html><body>Replaced!</body></html>

Examples

Use with http-proxy to modify proxied HTML

This library is most useful when used in conjunction with http-proxy and node-trumpet2.

Following code launches a local proxy on http://localhost:8008/ which serves contents of Google homepage, but injects a script at the bottom, that replaces Google logo image with "Boogle".

const express = require('express');
const fiddle = require('html-fiddle');
const trumpet = require('node-trumpet2');
const httpProxy = require('http-proxy');

const app = express();

// html-fiddle middleware has to be added before the proxy
app.use(fiddle({
    // we use trumpet() to parse and modify html elements
    // in a streaming fashion
    through: () => {
        const tr = trumpet();
        tr.select('body', (el) => {
            const es = el.createStream();
            // at the end, add extra markup
            es.on('end', () => es.write(
                `<script>
                    document.querySelector("#main img").removeAttribute("srcset");
                    document.querySelector("#main img").src = "https://booglebookclub.com/images/logo.png";
                </script>`
            ));
            // keep the rest of element contents
            es.pipe(es);
        });
        return tr;
    }
}));

// Proxy to Google homepage
const proxy = httpProxy.createProxyServer({
    target: "https://www.google.com/",
    changeOrigin: true
});

app.use((req, res) => proxy.web(req, res));

// If you visit http://localhost:8008/, you'll see Google search, with
// a modified image (because of the extra injected script)
app.listen(8008, () => console.log('Listening on http://localhost:8008/ ...'));

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the ISC License - see the LICENSE.md file for details

Acknowledgments

  • harmon - Initial inspiration to improve upon
  • http-proxy - Proxying content that prompted development of html-fiddle
  • node-trumpet2 - Maintained version of 'trumpet' that I wanted to use, hence the need to improve upon 'harmon'

Also, thanks @PurpleBooth, for the README template you created for all of us to use!