A free, web-based structogram (Nassi-Shneiderman diagram) editor with automatic code generation. Built entirely with web components β no framework dependencies.
- π Bidirectional pseudocode editing (visual β text)
- π German and English pseudocode support
- π» Code generation for Python, Java, and JavaScript
- πΎ Save/Load as JSON
- πΌ Export as PNG or SVG image
- π Shareable URLs (state compressed in URL hash, compatible with struktolab.openpatch.org)
- π¦ Web components β embed anywhere with zero dependencies
Full-featured visual editor with toolbar, pseudocode sync, and import/export.
<script src="https://cdn.jsdelivr.net/npm/struktolab/dist/editor/struktolab-editor.umd.min.js"></script>
<!-- Empty editor -->
<struktolab-editor font-size="14"></struktolab-editor>
<!-- With German pseudocode -->
<struktolab-editor font-size="14">
<script type="text/pseudocode">
eingabe("Zahl n")
ergebnis = 1
wiederhole fΓΌr i = 1 bis n:
ergebnis = ergebnis * i
ausgabe(ergebnis)
</script>
</struktolab-editor>
<!-- With English pseudocode -->
<struktolab-editor font-size="14" lang="en">
<script type="text/pseudocode">
input("number n")
result = 1
repeat for i = 1 to n:
result = result * i
output(result)
</script>
</struktolab-editor>
<!-- From JSON -->
<struktolab-editor font-size="14">
<script type="application/json">
{ "type": "TaskNode", "text": "x = 42" }
</script>
</struktolab-editor>| Attribute | Description | Default |
|---|---|---|
width |
Fixed width in pixels | auto |
font-size |
Font size in pixels | 14 |
lang |
Pseudocode language (de or en) |
de |
src |
URL to a JSON tree file | β |
color-mode |
Color mode (color, bw) |
color |
const editor = document.querySelector('struktolab-editor');
// Get/set tree
editor.tree = { type: "TaskNode", text: "hello" };
console.log(editor.tree);
// Pseudocode
editor.pseudocode = 'eingabe("Zahl n")';
// Code generation
editor.toCode('python'); // β Python code
editor.toCode('java'); // β Java code
editor.toCode('javascript'); // β JavaScript code
// Save/Load JSON (clean, no internal IDs)
const json = editor.saveJSON();
editor.loadJSON(json);
// Export image
const pngBlob = await editor.exportImage('png');
const svgBlob = await editor.exportImage('svg');
// Programmatic update
editor.change({ type: "TaskNode", text: "updated" });
// Listen for changes
editor.addEventListener('change', (e) => {
console.log('Tree changed:', e.detail.tree);
});Read-only SVG renderer for displaying structograms.
<script src="https://cdn.jsdelivr.net/npm/struktolab/dist/renderer/struktolab-renderer.umd.min.js"></script>
<struktolab-renderer font-size="14">
<script type="text/pseudocode">
falls x > 0:
ausgabe("positiv")
sonst:
ausgabe("nicht positiv")
</script>
</struktolab-renderer>Same attributes and tree format as the editor.
StruktoLab supports shareable URLs with the structogram state compressed in the URL hash using pako (zlib). This is compatible with existing URLs from struktolab.openpatch.org.
Example:
https://example.com/#pako:eNqlkstuE0EQRf-l166kH9Ov2UaJ...
The state is updated automatically as you edit.
- Node.js (v14+)
- npm
git clone https://github.com/openpatch/struktolab.git
cd struktog
npm installnpm run dev# App (index.html + bundled editor)
npm run build
# Component libraries (UMD + ES modules)
npm run build:renderer
npm run build:editor
# All at once
npm run build:allOutputs:
build/β app withindex.htmldist/renderer/βstruktolab-renderer.umd.js/.es.jsdist/editor/βstruktolab-editor.umd.js/.es.js
| Node | Description |
|---|---|
| Task | Simple statement |
| Input | Read input |
| Output | Write output |
| If/Else | Two-way branch |
| Switch/Case | Multi-way branch |
| While | Head-controlled loop |
| Do-While | Foot-controlled loop |
| For | Counter-controlled loop |
| Function | Function definition |
| Try/Catch | Exception handling |
MIT β see license.md
Based on the original structogram editor by Didaktik der Informatik, TU Dresden.