Signature
Parameters
string
required
The Mermaid diagram definition to validate.
ParseOptions
Options for parsing behavior.
Return value
object | false
Returns a
ParseResult object if the diagram is valid. If suppressErrors is true and the diagram is invalid, returns false instead of throwing.Throws
- Throws an error if the diagram is invalid and
suppressErrorsisfalseor not set - Error includes details about what is invalid in the diagram
Examples
Valid diagram
Invalid diagram with error suppression
Invalid diagram without error suppression
Validating user input
Detecting diagram type
Form validation
Extracting configuration
Batch validation
Usage notes
- Parse operations are queued and execute serially, similar to
render() - Does not produce any visual output or modify the DOM
- Lighter weight than
render()when you only need validation - Respects configuration from
initialize()for diagram parsing - The
parseErrorcallback (if set) is called when errors occur, unlesssuppressErrorsistrue
Queue behavior
Likerender(), parse operations are enqueued:
Related methods
- render() - Render a diagram to SVG
- run() - Render all diagrams in the document
- initialize() - Configure Mermaid