pgerd-to-drawio-diagram-converter
Try it out on: https://bertyhell.github.io/pgerd-to-drawio-diagram-converter
Programmatic interface
Installation:
npm install pgerd-to-drawio-diagram-converter
Use inside node:
import {convertPgerdToDrawIo} from 'pgerd-to-drawio-diagram-converter';
import * as fs from "fs";
const pgerdJsonString = fs.readFileSync('./diagram.pgerd').toString('utf-8');
const pgerdJson = JSON.parse(pgerdJsonString);
const drawIoXmlString = convertPgerdToDrawIo(pgerdJson);
fs.writeFileSync('./diagram.drawio.xml', drawIoXmlString);
Use inside a browser:
import { saveAs } from 'file-saver';
const pgerdDiagramJson: PgErdDiagramInfo = JSON.parse(pgerdJsonString);
const drawIoXml = convertPgerdToDrawIo(pgerdDiagramJson);
const blob = new Blob([drawIoXml], { type: 'text/xml;charset=utf-8' });
saveAs(blob, 'diagram.drawio.xml');
React example:
App.tsx