Registry / testing / plantuml-parser

plantuml-parser

JSON →
library0.4.0jsnpmunverified

A feature-incomplete but robust PEG-based parser for PlantUML syntax, written in JavaScript/TypeScript. Version 0.4.0 (latest) as of 2021, low release cadence. Designed to be used as a library or CLI. Key differentiators: focuses on graceful degradation, parsing partial diagrams without full syntax knowledge, and maintains a large set of test fixtures for reverse engineering the informal PlantUML spec. Not yet feature-complete; contributions welcome.

npm install plantuml-parser
INSTALL
IMPORT
SIG · PLANTUML-PARSER
P
plantuml-parser
testingjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'plantuml-parser'
import parse from 'plantuml-parser'
Named export, not default. The package supports CommonJS and ESM.
parseFile
import { parseFile } from 'plantuml-parser'
const { parseFile } = require('plantuml-parser')
Named export. CommonJS require is still supported in older versions.
formatters
import { formatters } from 'plantuml-parser'
import formatters from 'plantuml-parser'
formatters is a named export containing multiple formatter functions.

Parse a simple class diagram from PlantUML and log the AST and formatted output.

import { parse, formatters } from 'plantuml-parser'; const plantuml = ` @startuml class Car class Engine Car *-- Engine @enduml `; const result = parse(plantuml); console.log(JSON.stringify(result, null, 2)); console.log(formatters.default(result));
Debug
Known issues
gotchaParser is not feature-complete; some PlantUML syntax elements or diagrams may fail to parse or produce incomplete results.
fix
Contribute to the parser or use alternative tools like plantuml.jar for full support.
affects: <0.5.0
deprecatedThe package uses PEG.js internally, which is in maintenance mode. No known plans to migrate to Peggy.
fix
Consider locking PEG.js version or migrating to a different parser if needed.
affects: >=0.1.0
gotchaparseFile expects glob patterns; if no files match, it will not throw an error but return an empty array.
fix
Verify file patterns and ensure at least one file matches.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Expected "@startuml", "@end", "@enduml", "@start", "@endjson", "@startjson", or [ \t\n\r] but "i" found.
Input does not start with valid PlantUML syntax (e.g., @startuml).
fix
Ensure the input starts with '@startuml' or a recognized start directive.
TypeError: formatters.default is not a function
Using an older version of plantuml-parser where formatters.default did not exist.
fix
Update to version 0.4.0 or later, or use formatters['default'] as an alternative.
Error: Cannot find module 'plantuml-parser'
Package not installed or not in node_modules.
fix
Run 'npm install plantuml-parser' and ensure the package is in dependencies.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
plantuml-parser — npm install plantuml-parser · libregistry