Building a Zero-Server SVG-to-Visio (.vsdx) Compiler in the Browser

Published on October 23, 2026

Building a Zero-Server SVG-to-Visio (.vsdx) Compiler in the Browser

AI tools are great at generating architecture diagrams and flowcharts as .svg files, but enterprise teams almost always ask for the final deliverable in Microsoft Visio (.vsdx). Importing an SVG directly into Visio usually flattens everything into uneditable paths, breaks text boxes into separate single-line fragments, and strips out connectors.

I built DoLess (GitHub) to solve this cleanly as a 100% client-side compiler in plain JavaScript, with zero backend uploads so confidential architecture diagrams never leave the browser.

Here is a look at the four trickiest engineering problems behind turning an SVG DOM into a valid, editable .vsdx archive.


1. What a .vsdx File Actually Is

Under the hood, a Visio .vsdx file is an Open Packaging Conventions (OPC) ZIP archive containing linked XML parts:

diagram.vsdx (ZIP)
├── [Content_Types].xml
├── _rels/.rels
└── visio/
    ├── document.xml
    ├── _rels/document.xml.rels
    └── pages/
        ├── pages.xml
        ├── _rels/pages.xml.rels
        └── page1.xml          # All shapes, groups, geometry, text & connectors

Using JSZip in memory, the browser can assemble all relationship manifests and page XML parts without touching a server. The real work happens inside visio/pages/page1.xml.


2. Coordinate Systems and Nested Groups

SVG and Visio disagree on almost every geometric convention:

Property SVG Microsoft Visio (.vsdx)
Origin (0, 0) Top-left corner Bottom-left corner
Y-Axis Direction Grows downward Grows upward
Units Pixels (px) / user units Inches (96 px = 1 in)
Shape Position Top-left (x, y) Center pin (PinX, PinY)

Every SVG element's affine transform matrix (translate, scale, rotate, matrix) has to be resolved before converting coordinates into Visio inches. When preserving nested <g> elements as native Visio <Shape Type="Group"> containers, child shapes also need localized coordinates relative to their parent group's bottom-left corner rather than the global page.


3. Normalizing Every SVG Path Command

SVG supports 10 path commands (M, L, H, V, C, S, Q, T, A, Z) in both absolute and relative variants, plus primitives like <rect>, <circle>, <ellipse>, <polygon>, and <polyline>.

Visio's ShapeSheet geometry section expects relative normalized rows (RelMoveTo, RelLineTo, RelCubBezTo) scaled from 0.0 to 1.0 inside each shape's bounding box (Width, Height). In src/svg-path-parser.js, every primitive and path command is normalized down to three primitives:

  • Straight segments (L, H, V, Z) map to RelLineTo.
  • Quadratic Beziers (Q, T) are degree-elevated to cubic Beziers (RelCubBezTo).
  • Elliptical arcs (A) are converted from endpoint parameterization to center parameterization and approximated as cubic Bezier segments.

That keeps the XML emitter simple while ensuring rounded rectangles, circles, and complex icons remain smooth, editable vector shapes inside Visio.


4. Making Text and Connectors Feel Native

Two details separate a "technically valid" .vsdx from one you actually want to edit:

  • Multi-line text merging: SVG has no native word wrapping, so exporters emit multiple <tspan> elements or vertically stacked <text> nodes inside a single flowchart box. Walking the DOM to cluster vertically aligned text nodes inside the same bounding box and emitting a single Visio <Text> block with per-line character runs (<cp IX="..."/>) keeps labels editable as one paragraph instead of five scattered fragments.
  • 1D Connectors and Arrowheads: Two-point <line> or <path> elements with marker-end attributes are promoted from 2D shapes into native Visio 1D connectors (ObjType="2", BeginX/Y, EndX/Y, EndArrow="4"), so dragging an endpoint behaves like a real Visio arrow.

Why Keep It 100% Client-Side?

Architecture diagrams often contain internal service names, IP ranges, or unpublished product plans. Running the SVG sanitizer, path math, XML builder, and ZIP packaging entirely in the browser eliminates both server hosting costs and privacy friction.

You can test it directly at doless.northecal.com or inspect the parser and test suite in hafiz-yss/doless-svg-to-vsdx.

Copyright © 2026 Hafiz Sani.

Drag to pan chart
Enlarged visual