How to export a diagram to draw.io (.drawio) format

The .drawio format is an open XML standard you can export to from most diagram tools and keep editing in draw.io, VS Code, or Confluence — with no vendor lock-in. Diagrams.so goes one step further: describe your architecture in plain English and it exports a native, editable .drawio file directly, so you skip the manual redraw.

How to export to .drawio from draw.io, Lucidchart, and Visio

How you export to .drawio depends on the tool you start from, because .drawio is draw.io's native format and most other tools only reach it through an import step. From draw.io / diagrams.net, the diagram already is a .drawio file. To save a portable copy, use File > Save as and keep the .drawio (XML) extension, or File > Export as > XML to write an uncompressed .drawio you can commit to Git. If you plan to version-control the file, open the Preferences panel and turn off 'Compressed' so the XML stays human-readable and diff-able. Lucidchart does not write .drawio directly. Export your Lucidchart document to Visio (.vsdx) or to a Visio XML file, then open draw.io and choose File > Import to bring it in; draw.io reads .vsdx and converts the shapes into editable mxCell elements. Expect some fidelity loss: Lucidchart's proprietary shapes may fall back to generic rectangles, and custom styling can shift, because you are crossing a format boundary rather than exporting a native file. Microsoft Visio follows the same path. draw.io imports .vsdx directly through File > Import, so a Visio drawing becomes an editable draw.io diagram that you can then save as .drawio. Complex Visio stencils and connectors usually survive the conversion, but always check connections and labels afterward. Once the diagram is open in draw.io as native content, every subsequent save is a true .drawio file with no further conversion needed.

Exporting an AI-generated diagram to .drawio

Manual export always starts from a diagram you already drew. An AI generator skips that step by producing the .drawio file for you. Diagrams.so takes a plain-English description of an architecture — for example, 'an ALB in front of an EC2 Auto Scaling group, an RDS PostgreSQL primary with a read replica, and an S3 bucket for static assets' — and returns a native .drawio diagram with the components laid out, connected, and labeled. The output is a real .drawio file, not a screenshot or a flattened image export. It opens in draw.io desktop, the VS Code Draw.io extension, Confluence, or any mxGraph-compatible editor, and every shape, connection, and style remains fully editable. Cloud icons are written as mxCell shape styles that reference the official AWS, Azure, GCP, Kubernetes, or OCI stencil libraries, so an S3 bucket renders as the S3 icon rather than a plain box. To export, generate the diagram from your description, then download and choose the .drawio option. Because the file follows standard mxGraphModel conventions with grid-aligned geometry and proper source and target references on edges, it drops straight into a Git repository beside the code it documents. From there you refine it by hand: move components, rename services, or add a caching layer. The AI handles the first-draft layout; you keep full ownership of the editable file. This matters most when you are starting from nothing or migrating rough notes into a diagram, where the slow part is not exporting but drawing the diagram in the first place.

Converting PNG or Mermaid to .drawio

Two of the most common export requests — turning a PNG into a .drawio, and turning Mermaid code into a .drawio — work very differently, because one is a raster image and the other is structured text. A PNG (or JPG) is a grid of pixels with no information about shapes, connections, or text as objects. draw.io cannot un-flatten a PNG into editable mxCell elements; importing a PNG only places the image on the canvas as a static background you can trace over. To get a truly editable .drawio from an image you have two realistic options: redraw it by hand, or use an AI tool that reconstructs the structure. Diagrams.so can take an uploaded image or document on its paid tiers and rebuild it as an editable .drawio rather than embedding a flat picture. Mermaid is different because it already describes the diagram as text. draw.io has built-in Mermaid support: use Arrange > Insert > Advanced > Mermaid, paste your Mermaid definition, and draw.io renders it as native, editable mxGraph shapes. Once inserted, it is ordinary draw.io content, so saving produces a standard .drawio file. This is the reliable path for flowcharts, sequence diagrams, and ER diagrams written in Mermaid. The distinction to remember: text-based sources like Mermaid convert cleanly because the structure is explicit, while image-based sources like PNG require either manual work or AI reconstruction, since the structure has to be inferred rather than read.

What the .drawio format is: mxGraphModel XML under the hood

The Draw.io file format is an XML document rooted in a <mxGraphModel> element. Every .drawio file you create, whether in Draw.io desktop, the browser editor, or a third-party tool, produces this same XML structure. The format was originally defined by the mxGraph JavaScript library, which JGraph Ltd developed and open-sourced. When JGraph rebranded their product from mxGraph to Draw.io and later to Diagrams.net, the underlying XML format remained unchanged. This stability is the format's greatest strength. A .drawio file created in 2015 opens without modification in the 2024 editor. The XML starts with an <mxGraphModel> root element containing attributes for page dimensions, grid size, and math rendering options. Inside it, a <root> element holds <mxCell> elements that represent every object in the diagram: shapes, connections, labels, groups, and the default parent cells (id='0' for the root and id='1' for the default layer). Each mxCell has an id, a style string, a value (the label text), and optional child elements like <mxGeometry> that define position, size, and control points. The format supports multiple pages through <diagram> wrapper elements, each containing its own <mxGraphModel>. Compressed .drawio files base64-encode and deflate the XML content within the diagram element. Uncompressed files store the XML as plain text, which is what you want for version control. Draw.io's Edit > Preferences > Compressed option controls this behavior.

File structure: mxCell elements, styles, and geometry

Every visual element in a .drawio diagram is an mxCell. A rectangle shape might look like: <mxCell id='2' value='API Gateway' style='rounded=1;whiteSpace=wrap;fillColor=#dae8fc;strokeColor=#6c8ebf;' vertex='1' parent='1'><mxGeometry x='200' y='100' width='120' height='60' as='geometry'/></mxCell>. The id uniquely identifies the cell. The value is the displayed text. The vertex='1' attribute marks it as a shape (as opposed to an edge). The parent='1' refers to the default layer. The style attribute is a semicolon-delimited list of key-value pairs that control appearance. Common style properties include: shape (the base shape type like 'mxgraph.aws4.lambda' for an AWS Lambda icon), fillColor and strokeColor for colors, fontSize and fontFamily for text, rounded for corner radius, and whiteSpace=wrap to enable text wrapping. Cloud provider icons use shape styles that reference specific stencil libraries. An AWS EC2 instance uses shape=mxgraph.aws4.ec2. An Azure VM uses shape=mxgraph.azure.virtual_machine. These stencil references map to SVG definitions in Draw.io's shape libraries. Connections between shapes are mxCell elements with edge='1' instead of vertex='1'. An edge cell has source and target attributes referencing the id values of the shapes it connects. The style on an edge controls arrow type (endArrow, startArrow), line style (dashed, curved, orthogonal), and stroke properties. mxGeometry on edges defines control points that route the connection path. The Array element within mxGeometry holds mxPoint entries for each waypoint along the edge. Groups are mxCell elements with container='1' in their style and child cells with their parent attribute set to the group's id. This nesting lets you create VPC boundaries containing subnets containing services, with each level maintaining proper parent-child relationships in the XML.

Why .drawio matters: portability versus proprietary format lock-in

Diagram formats create lock-in more quietly than most technology choices. Lucidchart stores diagrams in a proprietary format accessible only through their web application and API. Miro boards exist only within Miro. Figma files require Figma to open. If you cancel your subscription to any of these tools, your diagrams become inaccessible or require manual recreation in another format. The .drawio format is different. It's an open XML format that you can read, write, and manipulate with any text editor or XML parser. The file lives on your filesystem, in your Git repository, or on your cloud storage. No vendor controls access. If Draw.io disappeared tomorrow, your diagrams would still be readable by any tool that parses mxGraphModel XML, and you could write a parser in any language in an afternoon. Export-based portability is not the same as format portability. Lucidchart can export to PNG, SVG, or PDF, but those are rasterized or flattened outputs. You lose the ability to edit individual shapes, connections, and styles. Exporting a Lucidchart diagram to Visio format produces a .vsdx file, but the conversion is lossy: custom shapes become generic rectangles, and styling changes. The .drawio format preserves every attribute of every element because it is the native format, not an export target. For organizations that standardize on Draw.io for architecture diagrams, the format choice has a compounding effect. Hundreds of diagrams accumulate over years. When they're stored in an open format in Git repositories alongside the code they document, they remain accessible regardless of which tools the organization uses in the future. When they're stored in a proprietary SaaS tool, they become a liability during contract negotiations.

Where .drawio files work: desktop, VS Code, Confluence, Google Drive, Git

Draw.io Desktop (also called Diagrams.net Desktop) is an Electron-based application for macOS, Windows, and Linux. It reads and writes .drawio files natively with no account required, no internet connection needed, and no data sent to external servers. This makes it the preferred editor for organizations with strict data residency requirements. Diagrams stay on local machines or internal file shares. The Draw.io VS Code extension by Hediet turns VS Code into a diagram editor. Open any .drawio file in VS Code and it renders in a visual editor tab. Edit shapes, connections, and styles visually, then save. The file stays in your workspace alongside your code. This integration is why many development teams adopt .drawio: the diagram editor lives inside the tool they already use for 8 hours a day. The Atlassian Confluence integration embeds .drawio diagrams directly in wiki pages. The Draw.io plugin for Confluence Server, Data Center, and Cloud stores diagram data within Confluence but renders it using the same mxGraph engine. Teams can edit diagrams in context without switching applications. The diagrams update in real-time within the wiki page. Google Drive integration lets you create and edit .drawio files stored in Google Drive. The Draw.io Google Workspace add-on opens a full diagram editor within the Google Drive interface. Shared drives work, making it suitable for teams that use Google Workspace for collaboration. Git repositories are the most powerful storage for .drawio files because they enable version tracking, diff review, and branch-based editing. Store diagrams in a /docs/architecture/ directory next to the code they describe. When a pull request changes the architecture, include the updated .drawio file in the same commit. Reviewers can see both the code change and the diagram change in a single review.

Version control with .drawio: meaningful diffs and merge strategies

The .drawio XML format is text-based, which means Git tracks every change as a line-level diff. When you move a shape from position (200, 100) to (300, 150), the diff shows the mxGeometry element changing from x='200' y='100' to x='300' y='150'. When you change a label from 'Auth Service' to 'Identity Service,' the diff shows the value attribute changing. These diffs are meaningful and reviewable, unlike binary image formats where any change produces a complete file replacement. To get clean diffs, store .drawio files in uncompressed format. Compressed .drawio files base64-encode the XML content, which produces unreadable diffs. In Draw.io Desktop, go to Edit > Preferences and uncheck 'Compressed.' The resulting XML is larger but diffable. For repositories with many diagrams, the size increase is negligible compared to the review quality improvement. Merge conflicts happen when two branches modify the same diagram. Because .drawio is XML, Git's text-based merge can handle many cases automatically: one branch adds a shape and another modifies a different shape. Conflicts occur when both branches modify the same mxCell element. Resolve these by opening the conflicted file in Draw.io (after manually resolving the XML conflict markers), verifying the visual result, and committing. For teams that modify diagrams frequently, consider a convention where each major diagram component lives on a separate Draw.io page. This reduces the likelihood of merge conflicts since pages are separate <diagram> elements in the XML. GitHub, GitLab, and Bitbucket don't render .drawio files natively in pull request previews. Some teams work around this by exporting a PNG alongside the .drawio file and including both in the commit. The PNG provides a visual preview in the PR, and the .drawio file remains the editable source of truth. Automated CI/CD pipelines can generate the PNG from the .drawio file using draw.io's command-line export tool.

Common .drawio export problems

A handful of issues account for most 'my .drawio export is broken' reports, and each has a direct fix. Unreadable diffs in Git: if your committed .drawio file shows up as one long line of base64 gibberish, the file was saved compressed. Turn off compression in draw.io (Extras or Edit > Preferences, uncheck 'Compressed') and re-save. The XML becomes plain text, and Git can show line-level diffs of geometry and label changes. Missing or broken icons when opened elsewhere: shapes reference stencil libraries by name, for example shape=mxgraph.aws4.ec2. If a viewer does not have that library enabled, the shape can render as a placeholder. Opening the file in draw.io desktop or diagrams.net, which ship the standard libraries, resolves this. For custom stencils, enable the matching shape library before opening. The file will not open, or opens in the wrong app: a .drawio file is just XML, so double-clicking may launch a text editor or browser. Set draw.io desktop as the default application for .drawio, or open draw.io first and use File > Open. Renaming the extension between .drawio and .xml does not change the contents — both are valid. No preview in pull requests: GitHub, GitLab, and Bitbucket do not render .drawio in PR previews. A common convention is to export a PNG or SVG next to the .drawio file and commit both, so reviewers get a visual while the .drawio stays the editable source of truth. Fidelity loss after importing from another tool: diagrams imported from Lucidchart or Visio can shift styling or drop custom shapes, so check connections, labels, and grouping after import and fix them in draw.io before saving the final .drawio.

Generating .drawio files with AI instead of manual drawing

Creating .drawio files manually means opening Draw.io, dragging shapes from the sidebar, positioning them on the canvas, drawing connections, adjusting styles, and aligning everything to a grid. For a 10-component architecture diagram, this takes 15 to 30 minutes. The cognitive overhead is in the layout decisions: how far apart should components be? Where do connection lines route to avoid crossings? How do you group related components visually? AI diagram generation produces valid .drawio XML from natural language descriptions. You describe the system: 'A Next.js frontend behind CloudFront, an API Gateway routing to three Lambda functions, DynamoDB for user data, S3 for file storage, and SQS for background job processing.' The AI generates a complete mxGraphModel with correctly styled mxCell elements, proper geometry positioning, labeled connections, and cloud provider icons. The output file is identical in structure to one created manually in Draw.io. It opens, edits, and saves in every tool that supports the .drawio format. The shapes have proper style attributes. The connections have correct source and target references. The geometry is grid-aligned. This matters because the generated file isn't a screenshot or a locked export. It's a fully editable .drawio file. Move shapes, change labels, add components, modify styles. The AI handles the initial layout. You handle the refinements. Diagrams.so generates .drawio files from text descriptions with support for AWS, Azure, and GCP icon sets. Describe your architecture, select the cloud provider, and get a .drawio file that opens in Draw.io desktop, VS Code, Confluence, or any mxGraph-compatible editor. The output follows .drawio conventions with proper mxCell structure, labeled connections, and grid alignment, ready for version control alongside your code.

How to export a diagram to .drawio format

  1. 1

    Open your diagram in its source tool

    Open the diagram in the app that created it — draw.io/diagrams.net, Lucidchart, Visio, or an AI generator like Diagrams.so.

  2. 2

    Choose the .drawio or XML export

    In draw.io, use File > Save as (.drawio) or Export as > XML. From Lucidchart or Visio, export to .vsdx or Visio XML and use File > Import in draw.io, since they can't write .drawio directly. From Diagrams.so, download and pick the .drawio option.

  3. 3

    Turn off compression for version control

    If the file will live in Git, open Preferences and uncheck 'Compressed' so the XML stays plain text and produces readable diffs.

  4. 4

    Open the .drawio file to keep editing

    Open the exported .drawio in draw.io desktop, the VS Code Draw.io extension, or Confluence; every shape, connection, and style remains fully editable.

Real-world examples

Generate these diagrams with AI

Related guides

Frequently asked questions

Can you convert a PNG or image to an editable .drawio file?

Not directly in draw.io — a PNG is flat pixels, so importing it only adds a static background you can trace over, not editable shapes. To get a truly editable .drawio you either redraw it by hand or use an AI tool that reconstructs the structure. Diagrams.so can rebuild an uploaded image into an editable .drawio on its paid tiers.

Is a .drawio file the same as XML?

Yes. A .drawio file is an XML document rooted in an <mxGraphModel> element, so .drawio and .xml are interchangeable extensions for the same content and draw.io can save either. The one caveat is compression: enabling the 'Compressed' option base64-deflates the XML inside the file, which stays valid XML but is no longer human-readable or diff-able.

What apps can open a .drawio file?

draw.io/diagrams.net in the browser and draw.io Desktop open .drawio natively on macOS, Windows, and Linux. The VS Code Draw.io extension edits them inside your workspace, the Confluence and Google Drive add-ons open them in context, and any mxGraph-compatible editor reads the XML. Because it is plain XML, a text editor can open it too.

How do I export a Mermaid diagram to .drawio?

Use draw.io's built-in Mermaid support: open Arrange > Insert > Advanced > Mermaid, paste your Mermaid definition, and draw.io renders it as native, editable shapes. From that point it is ordinary draw.io content, so saving the file produces a standard .drawio. This works well for flowcharts, sequence diagrams, and ER diagrams written in Mermaid.

Can AI generate a .drawio file directly?

Yes. Describe your architecture in plain English and Diagrams.so generates an editable .drawio file directly, with the components connected and the correct AWS, Azure, GCP, Kubernetes, or OCI icons applied in seconds. The output is native .drawio — not a screenshot — so it opens and edits in draw.io, VS Code, or Confluence like any hand-drawn file.