posthtml/posthtml
PostHTML is a tool to transform HTML/XML with JS plugins
🔧 HTML/XML Transformer with Plain JS Plugins
A dead-simple pipeline: parse HTML into a tree, run small JS plugins on it, then serialize back to markup.
PostHTML is a minimal toolkit for transforming HTML or XML using lightweight JavaScript plugins. Its core contains nothing but an HTML parser, a node-tree API, and a stringifier — everything else lives in community plugins. Each plugin is just a plain function that receives a tree, transforms it, and returns the result.
✨ Highlights
- Tiny core: Only an HTML parser, a node-tree API, and a stringifier — no opinions, no magic.
- Plugin model: Plugins are plain JS functions operating on the tree; compose them freely.
- Sync & async: Process synchronously when possible, or asynchronously for plugins that support it.
- Directives: Strip or rewrite custom syntax (e.g.,
<?php ?>) before plugins touch the tree. - Rich ecosystem: CLI, Gulp, Grunt, Webpack (
html-loader+posthtml-loader), Rollup — pick what fits your build tool. - Parser flexibility: Swap
posthtml-parserfor any alternative likepugorsugarml. - Plugin ecosystem: Community plugins cover custom elements, SVG tag generation, attribute extension, template includes, BEM, and more.
- Zero-config setup:
npm init posthtmlornpm i -D posthtmlinstalls in seconds.
💡 Why it matters
PostHTML exists because most HTML-processing tools bundle their own parser, stringifier, and transformation logic into one monolithic package. PostHTML separates these concerns: the core stays tiny and replaceable, while the real power comes from plugins. This makes it trivial to swap parsers, add custom transformations, or integrate into any existing build pipeline without learning a new DSL. It's especially useful when you need to manipulate HTML structure programmatically (attribute rewriting, tag substitution, content injection) rather than just minify or clean up output.
#HTML #OpenSource #JavaScript #BuildTools #TiniX
Similar Projects
Discover other similar projects and AI models.
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
Reverse engineer anything with agents, from app behavior down to native binaries.
Firecrawl is the knowledge infrastructure to make your agents smarter. It connects your agents to the web, and to Alexandria, our library of everything else.
all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...
The fast, flexible, and elegant library for parsing and manipulating HTML and XML.