Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
All diagram types

Mermaid Requirement Diagram Syntax & Examples

Requirement diagrams connect requirement statements to each other and to the elements that satisfy them.

Examples

Copy an example, or open it in the live editor with this diagram already loaded.

Parent and child requirements

contains links a parent requirement to the more specific requirements under it.

requirementDiagram
    requirement auth {
        id: "1"
        text: "Users sign in before checkout"
        risk: high
        verifymethod: test
    }
    functionalRequirement password {
        id: "1.1"
        text: "Passwords are at least 12 characters"
        risk: medium
        verifymethod: test
    }
    functionalRequirement session {
        id: "1.2"
        text: "Sessions expire after 12 idle hours"
        risk: medium
        verifymethod: demonstration
    }
    auth - contains -> password
    auth - contains -> session

An element that satisfies a requirement

The element is the design object. satisfies points from that object to the requirement it covers.

requirementDiagram
    performanceRequirement latency {
        id: "2"
        text: "The editor previews a diagram in under 2 seconds"
        risk: medium
        verifymethod: test
    }
    element previewer {
        type: "simulation"
    }
    previewer - satisfies -> latency

Verification link

verifies connects the test element to the requirement. The verifymethod on the requirement says how it is checked.

requirementDiagram
    interfaceRequirement exportApi {
        id: "3"
        text: "Export accepts png, svg, and pdf"
        risk: low
        verifymethod: test
    }
    element exportSuite {
        type: "test"
    }
    exportSuite - verifies -> exportApi

What is a Requirement Diagram?

A Mermaid requirement diagram is a traceability sketch in the style of SysML. Each requirement has an id, a text statement, a risk, and a verifymethod (analysis, inspection, test, or demonstration). Types include requirement, functionalRequirement, performanceRequirement, interfaceRequirement, and designConstraint. Elements represent the design thing that satisfies or verifies a requirement. Relationships include contains, copies, derives, satisfies, verifies, refines, and traces. Use this when a review needs the links, not when you only need a process flowchart.

When to use it

Use a requirement diagram for a spec review or a compliance trace. Use a flowchart for the behavior that satisfies the requirement. Use a class or ER diagram for the data model the requirement constrains.

Edit this requirement diagram in the live editor, read the Mermaid cheat sheet, or compare it with Flowchart, Class Diagram and ER Diagram.

Common Use Cases

  • •Systems engineering - Document and trace system requirements
  • •Compliance documentation - Show requirement verification methods
  • •Software specifications - Map functional and non-functional requirements
  • •Traceability - Link requirements to design elements
  • •Risk management - Visualize requirement risk levels

Syntax Quick Reference

ElementSyntaxDescription
Requirementrequirement name { }Define a generic requirement
FunctionalfunctionalRequirement name { }Functional requirement
PerformanceperformanceRequirement name { }Performance requirement
Elementelement name { type: sim }System element
RelationshipA - contains -> BRequirement relationship
SatisfiesA - satisfies -> BElement satisfies requirement

Syntax tips

  • •Every requirement needs an id, text, risk, and verifymethod. Quote the id and the text.
  • •risk is typically low, medium, or high. verifymethod is analysis, inspection, test, or demonstration.
  • •Pick the requirement type that matches the statement: functionalRequirement, performanceRequirement, interfaceRequirement, or designConstraint.
  • •An element has a type, such as simulation or test. It is the thing in the design, not another requirement.
  • •Relationships are written source - contains -> target. satisfies and verifies usually point from the element to the requirement.

Common mistakes

Leaving out risk or verifymethod.

Mermaid expects those fields on a requirement. Add both even when the review has not settled them yet.

Pointing satisfies from the requirement to the element.

Write element - satisfies -> requirement. The element is what does the satisfying.

Writing a process flow inside the requirement text and hoping the diagram shows the steps.

Keep the text to one statement. Draw the steps as a flowchart and link the element back to the requirement.

Export Options

Traceability diagrams get read in reviews. SVG keeps the requirement text sharp. Free PNG exports include a watermark.

Got Mermaid code from ChatGPT? Paste it here to render and export instantly.

Get the Free Mermaid Syntax Cheat Sheet

Free Mermaid Syntax Cheat Sheet

All 21 diagram types in one PDF reference.

Frequently Asked Questions

Ready to create your own requirement diagram?

Open the editor with this example pre-loaded and start customizing.

Related Diagram Types

All diagram types