{"id":93,"date":"2026-05-26T08:05:43","date_gmt":"2026-05-26T08:05:43","guid":{"rendered":"https:\/\/www.vpascode.com\/es\/docs\/uncategorized\/mermaid-js-playbook\/mermaid-js-class-diagram-guide\/"},"modified":"2026-07-30T01:21:17","modified_gmt":"2026-07-30T01:21:17","slug":"mermaid-js-class-diagram-syntax-guide","status":"publish","type":"ld_docs","link":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/","title":{"rendered":"Mermaid.js Class Diagram Syntax Guide"},"content":{"rendered":"<h2>What is a Class Diagram?<\/h2>\n<p>A <strong>Class Diagram<\/strong> is a structural <strong>UML diagram<\/strong> that visualizes the static architecture of an object-oriented software system. As an indispensable <strong>UML diagram type<\/strong>, it maps out the individual classes, interfaces, and data models within your application, explicitly documenting their internal fields (attributes), operational functions (methods), and the structural relationships that bind them together. This blueprint is vital for software engineers who need to translate high-level domain designs into clean, maintainable object structures.<\/p>\n<p>With <strong>Mermaid.js<\/strong>, you can outline your data models and system services using intuitive, text-based definitions. The layout engine automatically calculates box sizes, structures standard UML data compartments, and aligns relational arrows across your canvas without any manual formatting overhead.<\/p>\n<h2>Core Syntax Guide: Elements and Constructs<\/h2>\n<p>To design an accurate, standards-compliant UML class diagram in Mermaid, you must master member declarations, access modifiers, and structural relationship arrows.<\/p>\n<h3>1. Declaring Classes and Class Compartments<\/h3>\n<p>You can define a class using two valid formats. For a simple class, use the <code>class<\/code> keyword followed by the class name. If you want to include fields and methods immediately, use trailing curly braces to create a clear body block:<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAgmSQiEJocWpRQFF+WmZOqkI1RAIEtINLijLz0hVKgdJ5ibmpmDKpuYmZOUjCpQUpiSWpriBRjbzUcjBDU6EsPzMFoqgWAOaDJdQ=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">classDiagram\r\n    class UserProfile {\r\n        +String username\r\n        +String email\r\n        +updateEmail(newEmail) void\r\n    }<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAgmSQiEJocWpRQFF+WmZOqkI1RAIEtINLijLz0hVKgdJ5ibmpmDKpuYmZOUjCpQUpiSWpriBRjbzUcjBDU6EsPzMFoqgWAOaDJdQ=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"QKYoRec\"><img fetchpriority=\"high\" decoding=\"async\" width=\"303\" height=\"184\" class=\"alignnone size-full wp-image-618 \" src=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19030c532c9.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19030c532c9.png 303w, https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19030c532c9-300x182.png 300w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/p>\n<h3>2. Adding Visibility \/ Access Modifiers<\/h3>\n<p>To document standard UML encapsulation rules, place a specific symbol directly before your attribute or method name to define its visibility level:<\/p>\n<ul>\n<li><code>+<\/code> **Public:** Accessible from any other class.<\/li>\n<li><code>-<\/code> **Private:** Accessible only within the declaring class.<\/li>\n<li><code>#<\/code> **Protected:** Accessible within the class and its subclasses.<\/li>\n<li><code>~<\/code> **Package \/ Internal:** Accessible within the same package boundary.<\/li>\n<\/ul>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAgmSQiIJTYl62Y3JyfmleiUI1RAIEdFPyS5NyUhWSEnMS85JTERLKwSVFmXnpCokQPR75OSmpRQhp7fTUEieIHg1NBYghENlaANmyJWY=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">classDiagram\r\n    class BankAccount {\r\n        -double balance\r\n        #String accountHolder\r\n        +getBalance() double\r\n    }<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAgmSQiIJTYl62Y3JyfmleiUI1RAIEdFPyS5NyUhWSEnMS85JTERLKwSVFmXnpCokQPR75OSmpRQhp7fTUEieIHg1NBYghENlaANmyJWY=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"XgBkvsQ\"><img decoding=\"async\" width=\"249\" height=\"184\" class=\"alignnone size-full wp-image-619 \" src=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a1903106882d.png\" alt=\"\" \/><\/p>\n<h3>3. Mastering Relationship Arrows and Inheritance Links<\/h3>\n<p>To show how classes interact within your UML diagram model, connect their IDs using specialized relationship strings. In Mermaid, the direction of the line matters: the arrow head points toward the parent or container class.<\/p>\n<ul>\n<li><strong>Inheritance \/ Generalization (Dashed or Solid Arrow):<\/strong> <code>Child --|&gt; Parent<\/code> (Represents an \u00abis-a\u00bb relationship).<\/li>\n<li><strong>Realization \/ Implementation:<\/strong> <code>Class ..|&gt; Interface<\/code> (Represents a class fulfilling an interface contract).<\/li>\n<li><strong>Composition (Solid Diamond):<\/strong> <code>Child --* Parent<\/code> (Represents strict ownership; if the parent dies, the child dies).<\/li>\n<li><strong>Aggregation (Clear Diamond):<\/strong> <code>Child --o Parent<\/code> (Represents a loose collection relationship; the child can exist independently).<\/li>\n<li><strong>Dependency:<\/strong> <code>ClassA ..&gt; ClassB<\/code> (Represents a transient runtime reference).<\/li>\n<\/ul>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAAufEIgVd3Ro7hbDUjMzknFQFKwUlz7yM1KLMkmKFtKL8XCWIOte89My8VKBSLbAWkKpihYLEohKF\/DQlAHyeGXI=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">classDiagram\r\n    Car --|&gt; Vehicle : \"Inherits from\"\r\n    Engine --* Car : \"Is part of\"<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLzkksLnbJTEwvSszl5VIAAufEIgVd3Ro7hbDUjMzknFQFKwUlz7yM1KLMkmKFtKL8XCWIOte89My8VKBSLbAWkKpihYLEohKF\/DQlAHyeGXI=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"wCxJKDf\"><img decoding=\"async\" width=\"123\" height=\"416\" class=\"alignnone size-full wp-image-620 \" src=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a1903163fbcf.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a1903163fbcf.png 123w, https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a1903163fbcf-89x300.png 89w\" sizes=\"(max-width: 123px) 100vw, 123px\" \/><\/p>\n<h2>Best Practices for Clean Class Architecture Layouts<\/h2>\n<ul>\n<li><strong>Group Class Members Visually:<\/strong> Always group your class variables at the top of the body block and your functions at the bottom. This layout matches standard IDE class structures and makes your diagrams instantly readable.<\/li>\n<li><strong>Specify Return Types:<\/strong> When declaring methods, append the return type to the end of the method line (e.g., <code>+fetchData() DataSet<\/code>). This gives your engineering team precise implementation context.<\/li>\n<li><strong>Keep Multiplicity Clear:<\/strong> To indicate array counts or collection sizes, append multiplicity text strings directly to the relationship line wrapper (e.g., <code>Customer \"1\" --o \"many\" Order<\/code>).<\/li>\n<\/ul>\n<h2>Real-World Mermaid.js Class Diagram Examples<\/h2>\n<h3>Example 1: Payment Gateway Domain Subsystem (Encapsulation &amp; Interfaces)<\/h3>\n<p>This functional blueprint models an online checkout domain service. It demonstrates how to use access modifiers, group class members, and implement interface relationships cleanly.<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNq1UUFqw0AMvAfyhyWnhNI8IASfAsX0Ymj7AHVXcRd2pUUrtzVp\/147ToiTlNJLdBzNSDOSDZDzxkMtEKcT05XtEVNBG5G0EraYM4vZDd2+1mtPirIFi0Vxgu\/SQD5I5xC5IV2YV+aAQCOi4LYhd+TpJ5XugvY9nYzdPKn4hA+g+AHt2Mp936HaQPKP2F7jSC5x5\/ZFwm2M7pcFrp8FKINVzzTPCtrkhXln736N0w2sIPwRJ6LYNyAt3Y3Pe37Y5fKruP78yszKmAL2aJ4NuvME\/9H9AGFPu8s=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">classDiagram\r\n    class PaymentProcessor {\r\n        &lt;&lt;interface&gt;&gt;\r\n        +processPayment(amount) boolean\r\n        +refundPayment(txnId) boolean\r\n    }\r\n\r\n    class StripeGateway {\r\n        -String apiKey\r\n        -String endpointUrl\r\n        +processPayment(amount) boolean\r\n        +refundPayment(txnId) boolean\r\n        -logTransaction(status) void\r\n    }\r\n\r\n    class PayPalGateway {\r\n        -String merchantId\r\n        +processPayment(amount) boolean\r\n        +refundPayment(txnId) boolean\r\n    }\r\n\r\n    StripeGateway ..|&gt; PaymentProcessor : \"Implements\"\r\n    PayPalGateway ..|&gt; PaymentProcessor : \"Implements\"<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNq1UUFqw0AMvAfyhyWnhNI8IASfAsX0Ymj7AHVXcRd2pUUrtzVp\/147ToiTlNJLdBzNSDOSDZDzxkMtEKcT05XtEVNBG5G0EraYM4vZDd2+1mtPirIFi0Vxgu\/SQD5I5xC5IV2YV+aAQCOi4LYhd+TpJ5XugvY9nYzdPKn4hA+g+AHt2Mp936HaQPKP2F7jSC5x5\/ZFwm2M7pcFrp8FKINVzzTPCtrkhXln736N0w2sIPwRJ6LYNyAt3Y3Pe37Y5fKruP78yszKmAL2aJ4NuvME\/9H9AGFPu8s=\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"dKUznWo\"><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"480\" class=\"alignnone size-full wp-image-621 \" src=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19031bd8def.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19031bd8def.png 751w, https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a19031bd8def-300x192.png 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> The <code>&lt;&lt;interface&gt;&gt;<\/code> tag clearly marks `PaymentProcessor` as a high-level architectural contract. The two concrete gateway implementation classes use private fields (<code>-apiKey<\/code>) for sensitive credentials, while exposing public payment routines (<code>+processPayment<\/code>) linked via the realization arrow (<code>..|&gt;<\/code>).<\/p>\n<h3>Example 2: Enterprise Order Processing Engine (Composition &amp; Multiplicity)<\/h3>\n<p>This advanced system blueprint maps a complex e-commerce order management schema, demonstrating how to document structural ownership and object counts across multiple interconnected classes.<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNp1UctqAzEMvAfyD8KnNmEDufZQKJtLTi2k\/QDVFqnBj62spYTQf6\/3kcTbbX2wYEbjGcnaYUo7i0dGv1xAPrpDoG6TRE8M5wHtztoGAT0Se1MQB2EbjhDQU4E2DjU9syG+u4e+DuT3clFa9czMJ3boxGSHQmDyVTPlu6Cq0T\/riAO6g6C0qZBqdLp1WfQaBV1OY2L77uj\/OHshP4tkMzhJ1IGfLQaxcirg4XFo2Gp6IX4LVv50ejKGKdfzfJNJmEjmuJ46jWgTUx6rjub3RNdfVFsFVRVBeQwnNa78AVT8CkkNvbe51XazWXX9q153bdbRZye6CC7xh7cfb33pwzYJJKofTEiiUg==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">classDiagram\r\n    class Customer {\r\n        +int customerId\r\n        +String name\r\n        +placeOrder() Order\r\n    }\r\n\r\n    class Order {\r\n        +int orderId\r\n        +Date dateCreated\r\n        -String internalStatus\r\n        +calculateTotal() double\r\n    }\r\n\r\n    class OrderItem {\r\n        +int itemId\r\n        +int quantity\r\n        +double pricePerUnit\r\n    }\r\n\r\n    class Address {\r\n        +String street\r\n        +String city\r\n        +String postalCode\r\n    }\r\n\r\n    Customer \"1\" --o \"many\" Order : \"owns\"\r\n    OrderItem \"1..*\" --* \"1\" Order : \"composes\"\r\n    Address \"1\" --&gt; Order : \"ships to\"<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNp1UctqAzEMvAfyD8KnNmEDufZQKJtLTi2k\/QDVFqnBj62spYTQf6\/3kcTbbX2wYEbjGcnaYUo7i0dGv1xAPrpDoG6TRE8M5wHtztoGAT0Se1MQB2EbjhDQU4E2DjU9syG+u4e+DuT3clFa9czMJ3boxGSHQmDyVTPlu6Cq0T\/riAO6g6C0qZBqdLp1WfQaBV1OY2L77uj\/OHshP4tkMzhJ1IGfLQaxcirg4XFo2Gp6IX4LVv50ejKGKdfzfJNJmEjmuJ46jWgTUx6rjub3RNdfVFsFVRVBeQwnNa78AVT8CkkNvbe51XazWXX9q153bdbRZye6CC7xh7cfb33pwzYJJKofTEiiUg==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"nhNYQKB\"><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"450\" class=\"alignnone size-full wp-image-622 \" src=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png 731w, https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5-300x185.png 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> This example illustrates the difference between aggregation and composition. The solid diamond arrow (<code>--*<\/code>) shows that an `OrderItem` is tightly bound to an `Order` (if an order is deleted, its individual line items are destroyed too). Conversely, the clear diamond arrow (<code>--o<\/code>) indicates that a `Customer` owns multiple orders, but both entities can exist independently. Multiplicity strings (like <code>\"1..*\"<\/code>) define the relational requirements of the system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is a Class Diagram? A Class Diagram is a structural UML diagram that visualizes the static architecture of an object-oriented software system. As an indispensable UML diagram type, it maps out the individual classes, interfaces, and data models within&#8230;<\/p>\n","protected":false},"author":4,"featured_media":622,"parent":48,"menu_order":2,"template":"","meta":{"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"ld_collection":[14],"class_list":["post-93","ld_docs","type-ld_docs","status-publish","has-post-thumbnail","hentry","ld_collection-vpascode-docs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide<\/title>\n<meta name=\"description\" content=\"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide\" \/>\n<meta property=\"og:description\" content=\"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"VPasCode\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-30T01:21:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png\" \/>\n\t<meta property=\"og:image:width\" content=\"731\" \/>\n\t<meta property=\"og:image:height\" content=\"450\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/\",\"name\":\"Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/img_6a190321054b5.png\",\"datePublished\":\"2026-05-26T08:05:43+00:00\",\"dateModified\":\"2026-07-30T01:21:17+00:00\",\"description\":\"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/img_6a190321054b5.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/img_6a190321054b5.png\",\"width\":731,\"height\":450,\"caption\":\"Mermaid class diagram rendered from code using VPasCode text to diagram engine\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-class-diagram-syntax-guide\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lean Docs\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/%ld_collection%\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Mermaid.js Playbook\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Mermaid.js Class Diagram Syntax Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#website\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/\",\"name\":\"VPasCode\",\"description\":\"by Visual Paradigm\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#organization\",\"name\":\"VPasCode\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"width\":128,\"height\":138,\"caption\":\"VPasCode\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide","description":"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/","og_locale":"es_ES","og_type":"article","og_title":"Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide","og_description":"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.","og_url":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/","og_site_name":"VPasCode","article_modified_time":"2026-07-30T01:21:17+00:00","og_image":[{"width":731,"height":450,"url":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Tiempo de lectura":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/","url":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/","name":"Mermaid Class Diagram Syntax | VPasCode Text to Diagram Guide","isPartOf":{"@id":"https:\/\/www.vpascode.com\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png","datePublished":"2026-05-26T08:05:43+00:00","dateModified":"2026-07-30T01:21:17+00:00","description":"Document code structures and object relationships using Mermaid class diagrams in VPasCode, a free diagram-as-code tool.","breadcrumb":{"@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/#primaryimage","url":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png","contentUrl":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/05\/img_6a190321054b5.png","width":731,"height":450,"caption":"Mermaid class diagram rendered from code using VPasCode text to diagram engine"},{"@type":"BreadcrumbList","@id":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-class-diagram-syntax-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vpascode.com\/es\/"},{"@type":"ListItem","position":2,"name":"Lean Docs","item":"https:\/\/www.vpascode.com\/es\/docs\/%ld_collection%\/"},{"@type":"ListItem","position":3,"name":"Mermaid.js Playbook","item":"https:\/\/www.vpascode.com\/es\/docs\/vpascode-docs\/mermaid-js-playbook\/"},{"@type":"ListItem","position":4,"name":"Mermaid.js Class Diagram Syntax Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.vpascode.com\/es\/#website","url":"https:\/\/www.vpascode.com\/es\/","name":"VPasCode","description":"by Visual Paradigm","publisher":{"@id":"https:\/\/www.vpascode.com\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vpascode.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.vpascode.com\/es\/#organization","name":"VPasCode","url":"https:\/\/www.vpascode.com\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.vpascode.com\/es\/#\/schema\/logo\/image\/","url":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/06\/cropped-vp-online-logo-v1.png","contentUrl":"https:\/\/www.vpascode.com\/es\/wp-content\/uploads\/sites\/5\/2026\/06\/cropped-vp-online-logo-v1.png","width":128,"height":138,"caption":"VPasCode"},"image":{"@id":"https:\/\/www.vpascode.com\/es\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/ld_docs\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/ld_docs"}],"about":[{"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/types\/ld_docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/users\/4"}],"up":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/ld_docs\/48"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/media\/622"}],"wp:attachment":[{"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"ld_collection","embeddable":true,"href":"https:\/\/www.vpascode.com\/es\/wp-json\/wp\/v2\/ld_collection?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}