snyk-to-html is a Node.js utility designed to convert the JSON output from various Snyk CLI commands (e.g., `snyk test --json`, `snyk code test --json`, `snyk iac test --json`, `snyk container test --json`) into a human-readable, static HTML vulnerability report. The current stable version is 3.7.1, released in April 2026. The package sees a relatively active release cadence, often featuring bug fixes, security updates, and new features like adding support for exploit maturity, reachability signals, and risk scores. A key differentiator is its ability to accept custom Handlebars templates, allowing users to tailor the report's appearance and included data fields. It is primarily used as a CLI tool but also exposes a programmatic API for integration into automated workflows.
npm install snyk-to-htmlVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic conversion of Snyk JSON output into an HTML report using the `convertToHtml` function.
Upgrade your Node.js environment to version 20 or later using a tool like nvm or fnm.
Use ESM `import` syntax (`import { convertToHtml } from 'snyk-to-html';`) and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`). For CommonJS, dynamic import (`import('snyk-to-html')`) might be required.Review the `metadata` object structure in the documentation for each new major or minor version if you use custom templates. Use `{{#if metadata.fieldName}}` guards to prevent errors if fields are optional or absent.Update `snyk-to-html` to version 3.7.1 or newer (`npm update snyk-to-html`).
Install the package globally: `npm install -g snyk-to-html` or ensure your PATH includes `$(npm config get prefix)/bin`.
Ensure the Snyk JSON output is provided as a string. If using `convertToHtml`, `JSON.stringify()` the object before passing it.
Verify that the input JSON is valid Snyk CLI output. You can use `snyk test --json > output.json` and then validate `output.json` before passing it to `snyk-to-html`.