npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@klyratech/mermaid-to-visio

v0.1.0

Published

Convert a Mermaid-rendered SVG into a native Microsoft Visio drawing (.vsdx) with real shapes and connectors. Diagram-type agnostic. Brings no copy of Mermaid — you supply the official engine.

Readme

@klyratech/mermaid-to-visio

Convert a Mermaid-rendered SVG into a native Microsoft Visio drawing (.vsdx) — real shapes and connectors, not an embedded image. Diagram-type agnostic: it reproduces whatever primitives Mermaid draws.

This package contains no copy of Mermaid. You bring the official public Mermaid engine yourself (npm, CDN, or self-hosted) and pass it in. This package is the extension only.

Install

npm install @klyratech/mermaid-to-visio mermaid

mermaid is an optional peer dependency — required only if you use the renderToVisio(mermaid, …) convenience helper. If you already have a rendered SVG element, you can call svgElementToVsdx(svgEl) with no Mermaid at all.

Requirements

The conversion reads real geometry from the SVG (getBBox, getCTM, getPointAtLength, getComputedStyle), so it must run in a DOM environment: a browser, or Node with a headless browser (e.g. Puppeteer/Playwright). Pure jsdom will not work — it does not implement SVG layout. For a ready-made headless CLI, see @klyratech/visio-cli.

Usage

In the browser (you have a Mermaid instance)

import mermaid from 'mermaid';
import { renderToVisio } from '@klyratech/mermaid-to-visio';

mermaid.initialize({ startOnLoad: false, htmlLabels: false, flowchart: { htmlLabels: false } });

const { bytes, stats } = await renderToVisio(mermaid, 'diagram-id', 'flowchart TD\n A-->B', {
  title: 'My Diagram',
});
// `bytes` is a Uint8Array of a .vsdx file
new Blob([bytes], { type: 'application/vnd.ms-visio.drawing' });

Use htmlLabels:false so Mermaid emits <text> (not <foreignObject>); that is what makes the export reproduce labels faithfully.

From an existing SVG element (no Mermaid needed)

import { svgElementToVsdx } from '@klyratech/mermaid-to-visio';

const { bytes } = svgElementToVsdx(document.querySelector('svg'), { title: 'Diagram' });

API

| Export | Description | |--------|-------------| | renderToVisio(mermaid, id, definition, opts?) | Render Mermaid source → .vsdx. Async. Returns { bytes, stats }. | | svgElementToVsdx(svgEl, opts?) | Convert an already-rendered SVG element → .vsdx. Returns { bytes, stats }. | | captureSvgToDisplayList(svgEl) | Walk an SVG into a flat display list (polys + text) in SVG pixels. | | buildVsdxFromDisplayList(list, opts?) | Build the .vsdx package bytes from a display list. | | CoordinateSpace, boundsOf, normalizeColor | Lower-level helpers. |

opts: { title?: string }.

How it works

  1. Render with the official Mermaid to an SVG in the live DOM.
  2. Walk the SVG, sampling each primitive (rect/circle/ellipse/line/ poly*/path) into polygons and each <text> into a positioned run, mapped to root coordinates.
  3. Convert pixels → inches (96 px/in) and flip the Y axis (SVG y-down → Visio y-up); emit one Visio <Shape> per item.
  4. Assemble the Visio OPC part tree and zip it with a dependency-free store-only ZIP writer.

License

MIT © Klyra, AI-Enhanced Strategic Intelligence, Inc. — see LICENSE. "Microsoft" and "Visio" are trademarks of Microsoft Corporation; this project is not affiliated with or endorsed by Microsoft.