Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including snabbdom-to-html with all npm packages installed. Try it out:

var snabbdomToHtml = require("snabbdom-to-html")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

snabbdom-to-html v5.1.1

Render Snabbdom Vnodes to HTML strings

Snabbdom to HTML

Render Snabbdom Vnode’s to HTML strings


With npm do:

npm install snabbdom-to-html


var h = require('snabbdom/h')
var toHTML = require('snabbdom-to-html')

var output = toHTML(
  h('div', { style: { color: 'red' } }, 'The quick brown fox jumps')

// => <div style="color: red">The quick brown fox jumps</div>

Advanced usage

This library is built replicating the modular approach used in Snabbdom. So you can do the following if you need to implement any custom functionality.

var h = require('snabbdom/h')

var init = require('snabbdom-to-html/init')
var modules = require('snabbdom-to-html/modules')
var toHTML = init([

var output = toHTML(
  h('div', { style: { color: 'lime' } }, 'over the lazy fox')

// => <div style="color: lime">over the lazy fox</div>

The init function accepts an array of functions (modules). Modules have the following signature: (vnode, attributes) => undefined, where attributes is an ES2015 Map instance.

You can do attributes.set(key, value), attributes.get(key) and attributes.delete(key) and so on. You can check out the built-in modules to get the idea.

The built-in modules are available from snabbdom-to-html/modules, and these are:

  • attributes
  • class
  • props
  • style


This is tested against Node.js 4.x and up. If you need to run this in the browser you might need to include something like es6-shim to ensure Map support.



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free