UML to Code
Turn a Mermaid class diagram into TypeScript, Python, Java, or C# code — classes, interfaces, enums, inheritance, and relationships — live in your browser.
About the UML to Code
- Mermaid → TS, Python, Java, C#
- Live rendered diagram
- Send to Code to UML
- Instant results
- 100% private — runs in your browser
- Free, no sign-up
Describe your classes as a Mermaid class diagram and get ready-to-edit code in TypeScript, Python, Java, or C#. Fields, methods, visibility, inheritance, interfaces, enums, and relationships all map to the language’s idioms — so a diagram becomes a real starting point, not a picture you retype by hand.
The diagram is rendered live beside the editor as you type, so you can see the structure take shape and catch mistakes early. Change the target language and the same model re-emits instantly.
Everything runs in your browser — the diagram is parsed and the code generated entirely client-side, so nothing is uploaded. The generated shareable link carries your diagram in the URL, never on a server.
How to use it
- Write (or paste) a Mermaid class diagram in the left editor — start with the `classDiagram` keyword.
- Watch the live diagram render below and the code appear on the right.
- Pick a target language (TypeScript, Python, Java, or C#) to re-emit the same model.
- Copy or download the generated file, then flesh out the stubbed method bodies.
Supported Mermaid syntax
The common class-diagram constructs, mapped to code:
- class Foo { … }
- A class body containing fields and methods.
- + - # ~
- Visibility: public, private, protected, package/internal.
- <<interface>> / <<abstract>> / <<enumeration>>
- Stereotypes that change how a class is emitted.
- Animal <|-- Dog
- Inheritance — Dog extends Animal.
- Shape <|.. Circle
- Realization — Circle implements the Shape interface.
- Car *-- Engine
- Composition — becomes an Engine field on Car.
- Customer "1" --> "*" Order
- A "many" association becomes a collection field.
- List~Order~
- Mermaid generics map to List<Order> / Order[] / list[Order].
Frequently asked questions
Which UML diagrams are supported?+
Class diagrams, written in Mermaid’s classDiagram syntax. Class diagrams are the part of UML that maps deterministically to code; behavioural diagrams (sequence, state, activity) don’t translate to source and aren’t supported.
What do relationships become in the code?+
Inheritance becomes extends; realization becomes implements; composition, aggregation, and association become typed fields on the owning class — a collection when the multiplicity is "many" (for example "1" to "*"). Dependency arrows are shown in the diagram but not turned into fields.
Are the method bodies implemented?+
No — methods are generated as stubs (for example throwing "Not implemented" or raising NotImplementedError) so the code compiles as a skeleton you fill in. The tool models structure, not behaviour.
Is my diagram uploaded anywhere?+
No. Parsing, code generation, and the live diagram all run in your browser. Your shareable link stores the diagram in the URL fragment, which browsers never send to the server.
Can it also turn code back into a diagram?+
Not yet — this tool goes from diagram to code. Reverse (code to diagram) is planned. In the meantime you can paste a Mermaid class diagram and it opens here automatically via smart paste.
Works well with
UML to Code chains with these tools — send your result straight on:
Related tools
Code to UML
Turn TypeScript or Java source into a Mermaid class diagram — classes, interfaces, enums, fields, methods, inheritance, and interfaces — rendered live in your browser.
Color Converter
Convert colors between HEX, RGB, HSL, HSV, and OKLCH, with a picker, alpha, and a WCAG contrast checker — all in your browser.
CSS Unit Converter
Convert between CSS units — px, rem, em, pt, vw, vh, and more — with live visual feedback and a full conversion table.
Encoder / Decoder
Encode and decode text with Base64, URL, and Hex — UTF-8 safe, instant, and fully in your browser.
HEIC to JPG Converter
Convert iPhone HEIC/HEIF photos to JPG, PNG, or WebP — fast, multi-threaded batch conversion entirely in your browser. Nothing is uploaded, and location and metadata are removed by default.
Image Compressor
Fast, multi-threaded image compression — shrink many images at once by quality or to a target file size, with WebP/JPEG output and optional resizing, entirely in your browser.