
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
html-to-hyperscript
Advanced tools
html-to-hyperscript converts HTML to HyperScript.
Supports both original and
hypescript-helpers syntaxes.
Here and below first syntax is referenced as H, second – as HH.
$ npm install html-to-hyperscript
test.js
let {htmlToHs} = require("html-to-hyperscript")
let convert = htmlToHs({tabSize: 4})
console.log(
convert("<div>foo <span>bar</span></div>")
)
$ babel-node test.js
div([
`foo `,
span([`bar`])
])
Functions correspond to html-to-hyperscript default export.
Exported function are curried.
htmlToHs :: Opts -> String -> StringConverts HTML string to HyperScript string according to passed options.
> let convert = htmlToHs({})
> convert('<div class="foo"></div>')
'div(".foo")'
> convert('<a rel="stylesheet">public/bundle.css</a>')
'a({\n "attributes": {\n "rel": "stylesheet"\n }\n}, [`public/bundle.css`])'
> convert('<div><span>foo</span></div>')
'div([\n span([`foo`])\n])'
> let convert = htmlToHs({syntax: "h"})
> convert('<div><span>foo</span></div>')
'h("div", [\n h("span", [`foo`])\n])'
htmlToHs2 :: Opts -> String -> [String, [String]]Converts HTML string to HyperScript string according to passed options, keeping a list of used tagnames. Use with HH syntax.
> let [_, usedTagNames] = htmlToHs2({}, "<div><i>italic</i><b>bold #1</b><b>bold #2</b></div>")
> usedTagNames
['b', 'i', 'div']
> `let {${usedTagNames.join(", ")}} = hh(h)`.
'let {b, i, div} = hh(h)'
Opts :: {tabSize :: Number, syntax :: String}Options to control rendering.
tabSize – number of spaces in "tab". Defaults to 2.
syntax – pass "h" for H syntax, "hh" for HH syntax. Defaults to "hh".
| Feature | Library | ||
|---|---|---|---|
| html2hyperscript | html2hscript | html-to-hyperscript | |
| Parser engine | htmlparser2 | htmlparser2 | parse5 |
| Parsing | async | async | sync |
| H syntax | + | + | + |
| HH syntax | - | - | + |
| Respect whitespace | - | - | + |
This repo is made mostly to power a webservice.
So we don't care much about dependencies.
Use html-to-hyperscript.paqmind.com to convert HTML to HyperScript online.
MIT
FAQs
Convert HTML to HyperScript (both common syntaxes)
We found that html-to-hyperscript 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.