typediagram
v0.8.0
Published
typeDiagram CLI — parse a .td source file and emit SVG
Readme
typediagram
CLI for typeDiagram. Render the typeDiagram DSL to SVG, or convert between the DSL and TypeScript, Python, Rust, Go, and C#.
Live demo: typediagram.dev
Install
npm install -g typediagramUsage
# DSL → SVG (default)
typediagram schema.td > diagram.svg
# Source language → SVG
typediagram --from typescript types.ts > diagram.svg
# DSL → source language
typediagram --to rust schema.td > types.rs
# Read from stdin
cat schema.td | typediagram > diagram.svgOptions
| Flag | Values | Default |
| --------------- | ---------------------------------------------- | ------- |
| --from <lang> | typescript, python, rust, go, csharp | — |
| --to <lang> | typescript, python, rust, go, csharp | — |
| --emit <fmt> | svg, td, td+svg (for --from) | svg |
| --theme | light, dark | light |
| --font-size N | font size in px | — |
| -h, --help | show help | |
If no file is given, stdin is read. Output goes to stdout; errors go to stderr.
Example
cat > user.td <<'EOF'
typeDiagram
type User {
id: UUID
name: String
email: Option<Email>
}
union Option<T> {
Some { value: T }
None
}
alias Email = String
EOF
typediagram user.td > user.svgRelated packages
typediagram-core— core library (parser, layout, SVG renderer)- TypeDiagram VS Code extension — syntax highlighting + live preview (search "TypeDiagram" by nimblesite on the Marketplace)
Links
- Docs: typediagram.dev/docs
- Source: github.com/Nimblesite/typeDiagram
MIT © Nimblesite
