
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
horseless.decoder
Advanced tools
HTML templates with interpolated values.
HTML is great at one thing: describing how to build a web page. JavaScript is great at lots of things... but it's horrible at describing how to build a web page. This project turns an HTML template language into a JavaScript-accessible description of how to build a web page. It's then fairly easy to use JavaScript to follow the description and create elements matching the description
Horseless.decoder exposes one tag: h.
hh is a tag for literal strings. It accepts an HTML-like language and returns an array of descriptions of the described nodes as JavaScript objects.
h`<w a="b">c</w>x<y/>z`
becomes
[
{"type":"node","tag":"w","attributes":{"a":["b"]},"children":[
{"type":"textnode","value":"c"}
],"xmlns":"http://www.w3.org/1999/xhtml"},
{"type":"textnode","value":"x"},
{"type":"node","tag":"y","attributes":{},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"},
{"type":"textnode","value":"z"}
]
Note that attribute values are represented as arrays. This is to allow for data interpolation within attribute values.
let b = h`b`
h`a${b}c`
becomes
[
{"type":"textnode","value":"a"},
{"type":"textnode","value":"b"},
{"type":"textnode","value":"c"}
]
let tag = 'span'
h`<${tag} />`
becomes
[
{"type":"node","tag":"span","attributes":{},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"}
]
let x = '1'
let yz = { y: '2', z: '3' }
h`<a x=${x} ${yz}>`
becomes
[
{"type":"node","tag":"a","attributes":{"x":"1","y":"2","z":"3"},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"}
]
let wx = h`<w/><x/>`
h`<a>${wx[1]}<y/><z/></a>`
becomes
[
{"type":"node","tag":"a","attributes":{},"children":[
{"type":"node","tag":"x","attributes":{},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"},
{"type":"node","tag":"y","attributes":{},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"},
{"type":"node","tag":"z","attributes":{},"children":[],"xmlns":"http://www.w3.org/1999/xhtml"}
],"xmlns":"http://www.w3.org/1999/xhtml"}
]
If h is called as h(xmlns) the resulting xmlns attributes will default to the passed in value instead of http://www.w3.org/1999/xhtml
If the xmlns property is set in the HTML then the output node will use that property value for it's xmlns attribute. The xmlns of it's children will also be set to that property
h`<svg xmlns="http://www.w3.org/2000/svg"><p/></svg>`
becomes
[
{"type":"node","tag":"svg","attributes":{"xmlns":["http://www.w3.org/2000/svg"]},"children":[
{"type":"node","tag":"p","attributes":{},"children":[],"xmlns":"http://www.w3.org/2000/svg"}
],"xmlns":"http://www.w3.org/2000/svg"}
]
It doesn't check every box in the standard. It's close enough that you can paste any sane code and get what you're expecting with little-to-no manual cleanup. It handles void elements, boolean attributes, and unquoted attribute values (contributions welcome).
Handle closing tags better. Currently all closing tags are treated the same, closing whichever node was most recently opened. Mismatched nodes are handled with obliviosness. The bad HTML but obvious intention of <i>this part is italic <b>this part is bold and italic </i> this part is just bold</b> should be handled as intended (or it should error but that's not very HTML'y)
Better errors. Maybe give a hint as to where the error occurred?
FAQs
decoder for html-like template strings
We found that horseless.decoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.