# prisma-markdown

> Prisma Markdown documents generator including ERD diagrams and comment descriptions

Latest version **4.0.0** (published 2025-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install prisma-markdown
pnpm add prisma-markdown
yarn add prisma-markdown
bun add prisma-markdown
```

Provides the command `prisma-markdown`.

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-11-24 |
| First published | 2023-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 82.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 528 |
| Author | Jeongho Nam |
| Maintainers | samchon |
| Keywords | prisma, markdown, erd, mermaid, description, document, generator |

## Links

- npm: https://www.npmjs.com/package/prisma-markdown
- Repository: https://github.com/samchon/prisma-markdown
- Issues: https://github.com/samchon/prisma-markdown/issues
- npm.io page: https://npm.io/package/prisma-markdown

## Dependencies (1)

- [@prisma/generator-helper](https://npm.io/package/@prisma/generator-helper.md) ^7.0.0

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-11-24
- 2.0.0-dev.20250408 (next) — 2025-04-07
- 3.0.1 — 2025-05-17
- 3.0.0 — 2025-05-16
- 2.0.0 — 2025-04-07
- 1.0.9 — 2024-02-16
- 1.0.8 — 2023-12-27
- 1.0.8-dev.20231227 — 2023-12-27
- 1.0.8-dev.20231115 — 2023-11-15
- 1.0.7 — 2023-11-08
- 1.0.6 — 2023-11-05
- 1.0.5 — 2023-11-01
- 1.0.4 — 2023-10-25
- 1.0.3 — 2023-10-24
- 1.0.2 — 2023-10-24
- … 15 more at https://npm.io/package/prisma-markdown/versions

## README

# Prisma Markdown

## Outline

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/prisma-markdown/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/prisma-markdown.svg)](https://www.npmjs.com/package/prisma-markdown)
[![Downloads](https://img.shields.io/npm/dm/prisma-markdown.svg)](https://www.npmjs.com/package/prisma-markdown)
[![Build Status](https://github.com/samchon/prisma-markdown/workflows/build/badge.svg)](https://github.com/samchon/prisma-markdown/actions?query=workflow%3Abuild)

Prisma markdown documents generator.

- Mermaid ERD diagrams
- Descriptions by `///` comments
- Separations by `@namespace` comments

If you want to see how markdown document being generated, visit below examples:

- Markdown Content: [samchon/prisma-markdown/ERD.md](https://github.com/samchon/prisma-markdown/blob/master/ERD.md)
- Prisma Schema: [samchon/prisma-markdown/schema.prisma](https://github.com/samchon/prisma-markdown/blob/master/schema.prisma)

[![Example Case](https://github-production-user-asset-6210df.s3.amazonaws.com/13158709/268175441-80ca9c8e-4c96-4deb-a8cb-674e9845ebf6.png)](https://github.com/samchon/prisma-markdown/blob/master/ERD.md)

## Setup

At first, install NPM package.

```bash
npm i -D prisma-markdown
```

At next, add the generator to the schema file.

```prisma
generator markdown {
  provider = "prisma-markdown"
  output   = "./ERD.md"
  title    = "Shopping Mall"
}
```

At last, run below command, than [ERD.md](https://github.com/samchon/prisma-markdown/blob/master/ERD.md) file would be generated.

```bash
npx prisma generate
```

## Comment Tags

If your database has over hundreds of models, none of automatic ERD generators can express them perfect. In that case, `prisma-markdown` recommends you to separate hundreds of models to multiple paginated diagrams by using `/// @namespace <name>` comments.

When you write `/// @namespace <name>` comment on models, they would be separated to proper sections of markdown document. For reference, you can assign multiple `@namespace`s to a model, and if you do not assign any `@namespace` to a model, it would be assigned to `default` tag.

Also, if you use `@erd <name>` instead of `@namespace <name>`, target model would be expressed only at ERD. It would not be appeared to the markdown content section. Otherwise, `@describe <name>` tag will show the model only at markdown content section, not at ERD.

- `@namespace <name>`: Both ERD and markdown content
- `@erd <name>`: Only ERD
- `@describe <name>`: Only markdown content
- `@hidden`: Neither ERD nor markdown content
- `@minItems 1`: Mandatory relationship when 1: **N** (`||---|{`)

```prisma
/// Both description and ERD on Actors chatper.
///
/// Also, only ERD on Articles and Orders chapters.
///
/// @namespace Actors
/// @erd Articles
/// @erd Orders
model shopping_customers {
  /// The tag "minItems 1" means mandatory relationship `||---|{`.
  ///
  /// Otherwise, no tag means optional relationship `||---o{`.
  ///
  /// @minItems 1
  login_histories shopping_customer_login_histories[]
}

/// Only description on Actors chapter.
///
/// @describe Actors
model shopping_customer_login_histories {}

/// Only ERD on Articles chapter.
///
/// @erd Articles
model shopping_sale_reviews {}

/// Never be shown.
///
/// @hidden
model shopping_sale_hits {}
```

![Mandatory Relationship](https://github.com/samchon/prisma-markdown/assets/13158709/b382cf64-5047-4a00-b77f-7c3427010090)

Additionally, when defining 1: N relationship, you can specify the N position to be whether optional or mandatory. If you want to configure the N position to be mandatory, just write the `@minItems 1` comment tag. Otherwise the N position is optional, you don't need to do anything.

```prisma
model shopping_sale_units {
    /// @minItems 1
    stocks shopping_sale_snapshot_unit_stocks[];
    options shopping_sale_snapshot_unit_options[]; // optional
}
model shopping_sale_snapshot_unit_stocks {}
model shopping_sale_snapshot_unit_options {}
```

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