Fundamentals 7 min read

Boost Your Documentation: Generate PlantUML Diagrams Instantly with ChatGPT

This article explains how programmers can overcome the hassle of writing documentation by using ChatGPT to automatically generate PlantUML code, covering the basics of PlantUML, prompt engineering, and step‑by‑step examples for class and sequence diagrams.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Boost Your Documentation: Generate PlantUML Diagrams Instantly with ChatGPT

Many developers dislike writing documentation, finding it tedious compared to coding. The author discovered that using ChatGPT to generate PlantUML code can dramatically simplify the process.

What is PlantUML

PlantUML is a versatile tool that quickly creates various diagrams—sequence, use‑case, class, object, activity, component, deployment, state, and timing—using a simple, code‑like language. Although it requires some effort, its syntax resembles programming code and is easy to learn for anyone familiar with Markdown.

Example PlantUML code:

@startuml
!theme materia-outline
Client -> Server : Hello
@enduml

Visit the official site https://plantuml.com/zh/ for syntax details, or use the online editor https://www.plantuml.com/plantuml/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000 to render diagrams directly.

ChatGPT + PlantUML

If the built‑in PlantUML features are not “effortless” enough, you can let ChatGPT generate the diagram code. In the "Explore GPT" section, search for “PlantUML Diagram Wizard” (requires GPT‑4o or a Plus subscription). The free ChatGPT‑3.5 also works well, as do other large models like Kimi.

Prompt guidelines:

Specify the exact diagram type (e.g., class diagram, sequence diagram).

Provide a clear description of the desired diagram, as you would explain to a person.

If relevant, include code snippets and brief explanations.

Class Diagram Example

When you need a class diagram that shows relationships such as Controller calling Service, you can feed the relevant Java files to ChatGPT. First, tell the model you will send several files and ask it to remember their contents. Then, after uploading the files, prompt:

请帮我生成 PlantUML 格式的类图,请开始画图吧

ChatGPT will output PlantUML code, which you can paste into the online PlantUML editor to obtain the visual diagram.

Sequence Diagram Example

To illustrate a login flow, provide a prompt like:

以客户端、登录服务、数据库为3个主体,画出整个登录过程的Sequence diagrams:客户端输入手机号,调用登录服务,查询数据库,查看手机号是否存在,如果不存在,直接通知客户端用户不存,如果存在,登录服务查询数据库验证手机号和密码是否匹配,如果匹配,返回用户信息,客户端跳转到首页

ChatGPT interprets the description and returns PlantUML code, which you can render online to get the final sequence diagram.

Both local installation (Java or Docker) and editor plugins (e.g., VSCode) are available for generating PlantUML diagrams.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AutomationSoftware EngineeringChatGPTDocumentationPlantUMLUML
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.