# prisma-generator-plantuml-erd

> Provide a description about your generator

Latest version **1.7.1** (published 2025-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install prisma-generator-plantuml-erd
pnpm add prisma-generator-plantuml-erd
yarn add prisma-generator-plantuml-erd
bun add prisma-generator-plantuml-erd
```

Provides the command `prisma-generator-plantuml-erd`.

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2025-11-09 |
| First published | 2022-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.0 |
| Dependencies | 3 |
| Unpacked size | 262.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | osaki.shin |
| Maintainers | dbgso |
| Keywords | prisma, prisma2, generator, plantuml |

## Links

- npm: https://www.npmjs.com/package/prisma-generator-plantuml-erd
- Repository: https://github.com/dbgso/prisma-generator-plantuml-erd
- Homepage: https://github.com/dbgso/prisma-generator-plantuml-erd/tree/main/packages/generator
- Issues: https://github.com/dbgso/prisma-generator-plantuml-erd/issues
- npm.io page: https://npm.io/package/prisma-generator-plantuml-erd

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) 3.23.8
- [@prisma/client](https://npm.io/package/@prisma/client.md) 5.19.0
- [@prisma/generator-helper](https://npm.io/package/@prisma/generator-helper.md) 5.19.0

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.7.1 (latest) — 2025-11-09
- 1.6.0 — 2024-09-01
- 1.5.0 — 2024-08-25
- 1.4.0 — 2024-01-28
- 1.3.2 — 2023-11-06
- 1.3.1 — 2023-11-05
- 1.3.0 — 2023-11-05
- 1.2.1 — 2022-12-03
- 1.2.0 — 2022-12-03
- 1.1.0 — 2022-12-03
- 1.0.4 — 2022-11-10
- 1.0.3 — 2022-11-10
- 1.0.2 — 2022-11-08
- 1.0.1 — 2022-11-08
- 1.0.0 — 2022-11-08

## README

# prisma-generator-plantuml-erd

Prisma generator to create an ER Diagram for plantuml.


You can generate the plantuml source code from the schema.prisma.

![](https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/generator/usage.png)

# example

- `schema.prisma`
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/schema.prisma
- generated plantuml file
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example.puml
- generated image file
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/erd.svg

# usage


```bash
npm i -D prisma-generator-plantuml-erd
# or
yarn add -D prisma-generator-plantuml-erd
# or
pnpm add -D prisma-generator-plantuml-erd
```

Add to your schema.prisma

```prisma
generator erd_plantuml {
  provider   = "prisma-generator-plantuml-erd"
  output = "erd.puml"
  exportPerTables      = true
  showUniqueKeyLabel = true
  isShowForeignKeyOnRelation = true
  // markdownOutput       = "./example-tables.md"
  // markdownIncludeERD      = true
  // asciidocOutput       = "./example-tables.adoc"
  // asciidocIncludeERD      = true
}
```

*Please refer to the [Options](#options) section for the meaning of each option and set them accordingly.*

Run the generator

```
$ npx prisma generate
```

# Options

## enabled

Controls whether ER diagram generation is enabled or disabled.
The default value is true.

You can disable generation in two ways:

### 1. Via schema.prisma config
```prisma
generator erd_plantuml {
  provider = "prisma-generator-plantuml-erd"
  enabled = false  // Permanently disable generation
}
```

### 2. Via environment variable (recommended for dynamic control)
Set the `DISABLE_PLANTUML_ERD_GENERATION` environment variable to disable generation:

```bash
# Disable generation (local development)
DISABLE_PLANTUML_ERD_GENERATION=true npx prisma generate

# Or using 1 instead of true
DISABLE_PLANTUML_ERD_GENERATION=1 npx prisma generate

# Enable generation (default, CI environment)
npx prisma generate
```

**Use case example:**
```json
// package.json
{
  "scripts": {
    "prisma:generate": "DISABLE_PLANTUML_ERD_GENERATION=true prisma generate",
    "prisma:generate:ci": "prisma generate"
  }
}
```

**Priority:** Environment variable takes precedence over schema.prisma config.

This allows you to skip heavy ER diagram generation during local development while keeping it enabled in CI environments without modifying your schema.prisma file.

## output

The path of generated plantuml file path.
The default value is './erd.puml'

## usePhysicalTableName

If this flag is true, physical table name is used for name of table on er diagram.
The default value is false;


```
model User {
  id            String         @id

  @map("users")
}
```

If this flag is set to true, then "users" will be displayed on the diagram, otherwise "User" is displayed on the diagram.
 

## exportPerTables

If this flag is true, generate some tables 
If this flag is true, it also generate some diargrams that based on each table.
The diagrams is rendered with only the tables that related with base table.
The default value is false.

example

- all tables
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/erd.svg
- related with User table
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/User.svg
- related with Team table
  - https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/Team.svg
  

## lineLength

You can change the length of relation line by this option.
The default value is '--'.

In the default case

```
Table1 }o--o| Table3
```

if you set this flag to '---'

```
Table1 }o---o| Table3
```

# showUniqueKeyLabel

If this flag is true, unique column is also labeled as unique key on er diagram, like `[UK]`.
The default value is false.

# lineType

This parameter is used to change the type of relation line.
You can choose from the following three options:

- `ortho`
- `polyline`
- `unset`


The default value is `ortho`.

# isShowForeignKeyOnRelation

When set to true, foreign keys will be displayed on the relation lines.
The default value is false.

# relationMiniumOne

When set to true, the minimum cardinality in relations will be set to one (`|`) instead of zero (`o`).
The default value is false.

In PlantUML notation:
- `false` (default): `Table1 }o--o| Table2` (zero or more)
- `true`: `Table1 }|--|| Table2` (one or more)

This is useful when all your relations require at least one record.

# isLeftToRightDirection

When set to true, PlantUML's `left to right direction` will be specified.
The ER diagram will be drawn vertically.
This can be specified to improve the layout if the diagram becomes too wide horizontally.

# additionalPlantUMLParams

This is used when you want to specify options provided by PlantUML that are not individually prepared.
When setting multiple options, separate them with `;` as shown below, and they will be expanded line by line.

```
additionalPlantUMLParams = "scale 1280 width; hide circle;skinparam classFontColor red;skinparam classFontSize 10;skinparam classFontName Aapex;"
hide circle;skinparam classFontColor red;skinparam classFontSize 10;skinparam classFontName Aapex;
```

# markdownOutput

If this flag is set, a markdown table definition will be generated as well.

example
- https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/example-tables.md


The generated Markdown file can be converted to HTML or PDF using the following Docker image.

https://github.com/dbgso/docker-markdown-to-pdf-with-figures

# markdownIncludeERD

If this flag is true, an ER diagram for each table is generated on the table definitions
The default value is false.


# asciidocOutput

If this flag is set, a asciidoc table definition will be generated as well.

example
- https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/example-tables.adoc

# asciidocIncludeERD

If this flag is true, an ER diagram for each table is generated on the table definitions
The default value is false.


## Example

The example config is here.

```prisma
generator erd_plantuml {
  provider   = "prisma-generator-plantuml-erd"
  output               = "path/to/output.puml"
  lineLength           = "----"
  exportPerTables      = true
  usePhysicalTableName = false
  showUniqueKeyLabel = true
  markdownOutput       = "./example-tables.md"
  markdownIncludeERD      = true
  asciidocOutput       = "./example-tables.adoc"
  asciidocIncludeERD      = true
}
```

---
_Source: https://npm.io/package/prisma-generator-plantuml-erd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
