{"id":96,"date":"2026-05-26T08:05:44","date_gmt":"2026-05-26T08:05:44","guid":{"rendered":"https:\/\/www.vpascode.com\/in\/docs\/uncategorized\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/"},"modified":"2026-07-30T01:21:41","modified_gmt":"2026-07-30T01:21:41","slug":"mermaid-js-state-diagram-syntax-guide","status":"publish","type":"ld_docs","link":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/","title":{"rendered":"Mermaid.js State Diagram Syntax Guide"},"content":{"rendered":"<h2>What is a State Diagram?<\/h2>\n<p>A <strong>State Diagram<\/strong> (also known as a Statechart) is a behavioral <strong>UML diagram<\/strong> that models the finite lifecycle of a single object or subsystem. Recognized as a core <strong>UML diagram type<\/strong>, it illustrates the discrete conditions (states) an entity can occupy, the external events or triggers that force a shift between those conditions (transitions), and the conditional rule forks that alter execution pathways. This mapping is essential for tracking complex object lifecycles, such as an order&#8217;s progression from fulfillment to delivery, a user session timeout sequence, or an embedded hardware switch loop.<\/p>\n<p>With <strong>Mermaid.js<\/strong>, you can define your reactive state machines using a declarative, text-driven schema. The parsing engine automatically calculates optimal layout spacing, handles recursive looping arrows, and scales state container boundaries smoothly.<\/p>\n<h2>Core Syntax Guide: Elements and Constructs<\/h2>\n<p>To design an accurate, standards-compliant UML state diagram in Mermaid, you must master entry\/exit markers, transition strings, composite nesting, and conditional choice blocks.<\/p>\n<h3>1. Defining Entry, Exit, and Standard States<\/h3>\n<p>You initialize a state canvas on line one using the <code>stateDiagram-v2<\/code> keyword. Lifecycles require explicit starting and stopping points, which are represented by a solid circle symbol (<code>[*]<\/code>):<\/p>\n<ul>\n<li><strong>Initial State (Entry):<\/strong> <code>[*] --&gt; StateName<\/code> (Marks where the lifecycle starts).<\/li>\n<li><strong>Terminal State (Exit):<\/strong> <code>StateName --&gt; [*]<\/code> (Marks where the lifecycle concludes).<\/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:eNorLkksSXXJTEwvSszVLTPi5VIAgmitWAVdXTsFz5ScVIgIiAUWAkoBAHu\/DUo=\" \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\">stateDiagram-v2\r\n    [*] --&gt; Idle\r\n    Idle --&gt; [*]<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNorLkksSXXJTEwvSszVLTPi5VIAgmitWAVdXTsFz5ScVIgIiAUWAkoBAHu\/DUo=\" \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=\"SiHpwMe\"><img decoding=\"async\" width=\"60\" height=\"184\" class=\"alignnone size-full wp-image-634 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png\" alt=\"\" \/><\/p>\n<h3>2. Configuring Transition Triggers and Event Labels<\/h3>\n<p>To map a state change, connect your defined state tokens using a standard arrow line (<code>--&gt;<\/code>). To document the exact event, API response, or button click that causes this transition, append a colon (<code>:<\/code>) followed by your descriptive text string:<\/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:eNorLkksSXXJTEwvSszVLTPi5VIAAsfkksyyVAVdXTuF4NLigtS8lNQUBSuFgMTK3NS8ErfEzJzUFIhKhDRIMVSflYJnXll+ZnJqcGpJCVApAEGuIFE=\" \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\">stateDiagram-v2\r\n    Active --&gt; Suspended : PaymentFailed\r\n    Suspended --&gt; Active : InvoiceSettled<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNorLkksSXXJTEwvSszVLTPi5VIAAsfkksyyVAVdXTuF4NLigtS8lNQUBSuFgMTK3NS8ErfEzJzUFIhKhDRIMVSflYJnXll+ZnJqcGpJCVApAEGuIFE=\" \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=\"djvhsUF\"><img decoding=\"async\" width=\"245\" height=\"170\" class=\"alignnone size-full wp-image-635 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904116de63.png\" alt=\"\" \/><\/p>\n<h3>3. Implementing Conditional Choice Blocks<\/h3>\n<p>To handle branching evaluation loops, use the <code>&lt;&lt;choice&gt;&gt;<\/code> stereotype. This creates a clear diamond shape on the canvas that splits a single inbound transition path into multiple distinct outbound paths based on runtime logic checks:<\/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:eNorLkksSXXJTEwvSszVLTPi5VIAgmKQoEJyRmpydjyIXVqsYGOTnJGfmZxqZwdREq0Vq6Cra4eiCCKDog2kJKAoNTezNDe0OLVIwUohM00hKTEnMS85VcHOVsHQwACHruCSxLyUxKIUTG02IF0A7rQ5Ow==\" \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\">stateDiagram-v2\r\n    state check_status &lt;&lt;choice&gt;&gt;\r\n    [*] --&gt; check_status\r\n    check_status --&gt; PremiumUser : if balance &gt;= 100\r\n    check_status --&gt; StandardUser : if balance &lt; 100<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNorLkksSXXJTEwvSszVLTPi5VIAgmKQoEJyRmpydjyIXVqsYGOTnJGfmZxqZwdREq0Vq6Cra4eiCCKDog2kJKAoNTezNDe0OLVIwUohM00hKTEnMS85VcHOVsHQwACHruCSxLyUxKIUTG02IF0A7rQ5Ow==\" \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=\"HypodAD\"><img fetchpriority=\"high\" decoding=\"async\" width=\"298\" height=\"222\" class=\"alignnone size-full wp-image-636 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904161772d.png\" alt=\"\" \/><\/p>\n<h3>4. Structuring Composite (Nested) States<\/h3>\n<p>When modeling a complex system, a single high-level state can contain its own independent inner lifecycle. You can create a nested sub-state layout by defining a parent state followed by a body block wrapped in curly braces:<\/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:eNorLkksSXXJTEwvSszVLTPi5VIAgmKQoIJ\/UUpqUUBRfnJqcXFmXrpCNUQSBKK1YhV0de0UAhKTsxPTgZIIKbgQWIFPYlJqDly+FgAmQR80\" \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\">stateDiagram-v2\r\n    state OrderProcessing {\r\n        [*] --&gt; Packaging\r\n        Packaging --&gt; Labeling\r\n    }<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNorLkksSXXJTEwvSszVLTPi5VIAgmKQoIJ\/UUpqUUBRfnJqcXFmXrpCNUQSBKK1YhV0de0UAhKTsxPTgZIIKbgQWIFPYlJqDly+FgAmQR80\" \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=\"GxeUbLP\"><img loading=\"lazy\" decoding=\"async\" width=\"174\" height=\"335\" class=\"alignnone size-full wp-image-637 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a190419d2120.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a190419d2120.png 174w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a190419d2120-156x300.png 156w\" sizes=\"(max-width: 174px) 100vw, 174px\" \/><\/p>\n<h2>Best Practices for Clean State Machine Layouts<\/h2>\n<ul>\n<li><strong>Keep State Tokens Short:<\/strong> Use brief CamelCase text strings for your internal state tokens (e.g., <code>AwaitingRefund<\/code>). If you need a long descriptive title on the canvas, use the <code>state \"Descriptive Text Block\" as Token<\/code> syntax to create an explicit alias.<\/li>\n<li><strong>Enforce a Single Entry Point:<\/strong> Always start your diagram from a single <code>[*]<\/code> node. Having multiple starting points can confuse users trying to track the root initialization path of the system.<\/li>\n<li><strong>Always Use stateDiagram-v2:<\/strong> Always choose the <code>stateDiagram-v2<\/code> keyword over the legacy <code>stateDiagram<\/code> flag. The v2 rendering engine uses an updated layout algorithm that provides cleaner line routing and better nested box alignments.<\/li>\n<\/ul>\n<h2>Real-World Mermaid.js State Diagram Examples<\/h2>\n<h3>Example 1: Digital Wallet Transaction Lifecycle (Choice Branches &amp; Failure Loops)<\/h3>\n<p>This functional blueprint models the lifecycle of a digital payment transaction, showing how a transaction moves from an initial submission point through a fraud check fork into finalized ledger states.<\/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:eNp9kT9PwzAQxfdK\/Q6ekbIwVlWkQstUBMLdEEKHfbhW\/CeyzwG+PU5C3UBQPXi4e+\/9zudIQLjVoALYqrteLlg+sS+y9wBJvoojioat1+LotcC6Xi5GzfPVC6uqmh0CuMjTm9VEKMfe79ogm4at2O4TRSJ80rHZxIgxWnR0Sp5KC2HTtsF3OWzFehfjwgdke\/9xwXNnQKm\/lp3BDsqkk3lP6v+Q9+ASmHyDwvDQYQha4iXvFoXRbvDy\/NSg6eugLfpEM27B9GaORAb7bTyik9qpHHDrbV7kHmVmj765qoCzuDVIA\/kGXHOW8iRE3vSMX0btM\/KvTlrnsJ\/eN93zsSs=\" \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\">stateDiagram-v2\r\n    state fraud_check &lt;&lt;choice&gt;&gt;\r\n\r\n    [*] --&gt; TransSubmitted\r\n    TransSubmitted --&gt; fraud_check : ExecuteRiskAssessment\r\n\r\n    fraud_check --&gt; TransApproved : Risk Score Low\r\n    fraud_check --&gt; TransFlagged : Risk Score Elevated\r\n    \r\n    TransFlagged --&gt; TransApproved : ManualManagerOverride\r\n    TransFlagged --&gt; TransDeclined : SecurityTimeout\r\n    \r\n    TransApproved --&gt; SettlementPending : CommitLedger\r\n    SettlementPending --&gt; TransCompleted : BankSettlementSuccess\r\n    \r\n    TransDeclined --&gt; [*]\r\n    TransCompleted --&gt; [*]<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNp9kT9PwzAQxfdK\/Q6ekbIwVlWkQstUBMLdEEKHfbhW\/CeyzwG+PU5C3UBQPXi4e+\/9zudIQLjVoALYqrteLlg+sS+y9wBJvoojioat1+LotcC6Xi5GzfPVC6uqmh0CuMjTm9VEKMfe79ogm4at2O4TRSJ80rHZxIgxWnR0Sp5KC2HTtsF3OWzFehfjwgdke\/9xwXNnQKm\/lp3BDsqkk3lP6v+Q9+ASmHyDwvDQYQha4iXvFoXRbvDy\/NSg6eugLfpEM27B9GaORAb7bTyik9qpHHDrbV7kHmVmj765qoCzuDVIA\/kGXHOW8iRE3vSMX0btM\/KvTlrnsJ\/eN93zsSs=\" \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=\"FzzxFeh\"><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"742\" class=\"alignnone size-full wp-image-638 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19041e24943.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19041e24943.png 397w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19041e24943-161x300.png 161w\" sizes=\"(max-width: 397px) 100vw, 397px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> This workflow utilizes a <code>&lt;&lt;choice&gt;&gt;<\/code> block to evaluate safety scores right at the start. The transaction transitions along distinct pathways based on these scores, with clear event names (like <code>ExecuteRiskAssessment<\/code>) documented directly on the transition arrows.<\/p>\n<h3>Example 2: E-Commerce Order Fulfillment Pipeline (Composite Nested Systems)<\/h3>\n<p>This advanced enterprise blueprint outlines a complete shipping and order management lifecycle, using nested composite blocks to show the internal operations happening within the fulfillment phase.<\/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:eNplUEtPwzAMviPxH3JG6oXjDkis02DS0II4Ig6mcVdraVo5yUSF+O\/ksWop+BBF\/l62rQOHG4IjQ1+d729vRKj3uw9RVQ\/iwApZamhQZSC\/RTvRdmbrdUta92icWAkJU\/zVMDrPS6mNcX8E3xkqg3cOe0nNiczxChbNRHr1oMlNj15RTF2Da7qIz4mxFpwoesMmzLQeviRkp5VIoARrS+E\/XhTXwEzIL2CoRevEExrksJAKLnv4RC2ZjJttfsrFlyunSToaxyS92D6DUbaDE2bFjEfuBjWdkRP74N124EtnqgfTEvfLK1\/pURyO+gvdUZF9\" \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\">stateDiagram-v2\r\n    [*] --&gt; OrderPlaced\r\n    \r\n    OrderPlaced --&gt; InFulfillment : PaymentCaptured\r\n    \r\n    state InFulfillment {\r\n        [*] --&gt; ItemPicking\r\n        ItemPicking --&gt; QualityAudit : BatchPicked\r\n        QualityAudit --&gt; SecureBoxPacking : AuditPassed\r\n        SecureBoxPacking --&gt; CarrierManifest Generated : LabelPrinted\r\n    }\r\n    \r\n    InFulfillment --&gt; Shipped : CarrierHandshake\r\n    Shipped --&gt; Delivered : OutForDeliveryConfirmed\r\n    \r\n    Delivered --&gt; [*]<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNplUEtPwzAMviPxH3JG6oXjDkis02DS0II4Ig6mcVdraVo5yUSF+O\/ksWop+BBF\/l62rQOHG4IjQ1+d729vRKj3uw9RVQ\/iwApZamhQZSC\/RTvRdmbrdUta92icWAkJU\/zVMDrPS6mNcX8E3xkqg3cOe0nNiczxChbNRHr1oMlNj15RTF2Da7qIz4mxFpwoesMmzLQeviRkp5VIoARrS+E\/XhTXwEzIL2CoRevEExrksJAKLnv4RC2ZjJttfsrFlyunSToaxyS92D6DUbaDE2bFjEfuBjWdkRP74N124EtnqgfTEvfLK1\/pURyO+gvdUZF9\" \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=\"TYltJdW\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"1083\" class=\"alignnone size-full wp-image-639 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904232f697.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904232f697.png 381w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904232f697-106x300.png 106w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1904232f697-360x1024.png 360w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> By wrapping steps inside the <code>state InFulfillment {...}<\/code> body block, you create a clear structural boundary on the canvas. The engine treats this block as a single consolidated parent state while rendering its internal workflow steps sequentially, making complex multi-layered lifecycles easy to navigate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is a State Diagram? A State Diagram (also known as a Statechart) is a behavioral UML diagram that models the finite lifecycle of a single object or subsystem. Recognized as a core UML diagram type, it illustrates the discrete&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":48,"menu_order":5,"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-96","ld_docs","type-ld_docs","status-publish","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 State Diagram Syntax | VPasCode Text to Diagram Guide<\/title>\n<meta name=\"description\" content=\"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud 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\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/\" \/>\n<meta property=\"og:locale\" content=\"hi_IN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mermaid State Diagram Syntax | VPasCode Text to Diagram Guide\" \/>\n<meta property=\"og:description\" content=\"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud diagram-as-code tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"VPasCode\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-30T01:21:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0905\u0928\u0941\u092e\u093e\u0928\u093f\u0924 \u092a\u0922\u093c\u0928\u0947 \u0915\u093e \u0938\u092e\u092f\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 \u092e\u093f\u0928\u091f\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/\",\"name\":\"Mermaid State Diagram Syntax | VPasCode Text to Diagram Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a19040d605c9.png\",\"datePublished\":\"2026-05-26T08:05:44+00:00\",\"dateModified\":\"2026-07-30T01:21:41+00:00\",\"description\":\"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud diagram-as-code tool.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/#breadcrumb\"},\"inLanguage\":\"hi-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"hi-IN\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a19040d605c9.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a19040d605c9.png\",\"width\":60,\"height\":184},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-state-diagram-syntax-guide\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lean Docs\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/%ld_collection%\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Mermaid.js Playbook\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Mermaid.js State Diagram Syntax Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#website\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\",\"name\":\"VPasCode\",\"description\":\"by Visual Paradigm\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"hi-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#organization\",\"name\":\"VPasCode\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"hi-IN\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"width\":128,\"height\":138,\"caption\":\"VPasCode\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mermaid State Diagram Syntax | VPasCode Text to Diagram Guide","description":"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud 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\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/","og_locale":"hi_IN","og_type":"article","og_title":"Mermaid State Diagram Syntax | VPasCode Text to Diagram Guide","og_description":"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud diagram-as-code tool.","og_url":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/","og_site_name":"VPasCode","article_modified_time":"2026-07-30T01:21:41+00:00","og_image":[{"url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"\u0905\u0928\u0941\u092e\u093e\u0928\u093f\u0924 \u092a\u0922\u093c\u0928\u0947 \u0915\u093e \u0938\u092e\u092f":"4 \u092e\u093f\u0928\u091f"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/","url":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/","name":"Mermaid State Diagram Syntax | VPasCode Text to Diagram Guide","isPartOf":{"@id":"https:\/\/www.vpascode.com\/in\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png","datePublished":"2026-05-26T08:05:44+00:00","dateModified":"2026-07-30T01:21:41+00:00","description":"Define system behavior and event triggers with Mermaid state diagrams in VPasCode, a cloud diagram-as-code tool.","breadcrumb":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/#breadcrumb"},"inLanguage":"hi-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/"]}]},{"@type":"ImageObject","inLanguage":"hi-IN","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/#primaryimage","url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png","contentUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a19040d605c9.png","width":60,"height":184},{"@type":"BreadcrumbList","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-state-diagram-syntax-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vpascode.com\/in\/"},{"@type":"ListItem","position":2,"name":"Lean Docs","item":"https:\/\/www.vpascode.com\/in\/docs\/%ld_collection%\/"},{"@type":"ListItem","position":3,"name":"Mermaid.js Playbook","item":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/"},{"@type":"ListItem","position":4,"name":"Mermaid.js State Diagram Syntax Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.vpascode.com\/in\/#website","url":"https:\/\/www.vpascode.com\/in\/","name":"VPasCode","description":"by Visual Paradigm","publisher":{"@id":"https:\/\/www.vpascode.com\/in\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vpascode.com\/in\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"hi-IN"},{"@type":"Organization","@id":"https:\/\/www.vpascode.com\/in\/#organization","name":"VPasCode","url":"https:\/\/www.vpascode.com\/in\/","logo":{"@type":"ImageObject","inLanguage":"hi-IN","@id":"https:\/\/www.vpascode.com\/in\/#\/schema\/logo\/image\/","url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/06\/cropped-vp-online-logo-v1.png","contentUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/06\/cropped-vp-online-logo-v1.png","width":128,"height":138,"caption":"VPasCode"},"image":{"@id":"https:\/\/www.vpascode.com\/in\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs"}],"about":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/types\/ld_docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/users\/4"}],"up":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs\/48"}],"wp:attachment":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"ld_collection","embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_collection?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}