npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mermaid-flowchart-parser

v0.1.1

Published

Dependency-free parser that recovers node ids and edges from Mermaid flowchart source, without pulling in mermaid's rendering pipeline.

Readme

mermaid-flowchart-parser

Recovers node ids and edges from Mermaid flowchart source. No mermaid dependency, no rendering pipeline (no d3, cytoscape, katex, or roughjs) — just the text.

Why

Mermaid's own flowchart grammar (flow.jison) isn't exposed as a standalone, render-free API (mermaid-js/mermaid#4401 tracks migrating it off jison; flowchart hasn't moved yet). If you need "what node ids does this diagram declare" or "what connects to what" — for example, to check a Mermaid diagram against a separate source of truth — pulling in all of mermaid for that is a lot of dependency weight for two questions.

This library is not a complete, spec-accurate flowchart grammar. It covers the common cases well: bracket/paren/brace node shapes, solid/dotted/thick arrows, arrow-tip variants (--x, --o, <-->), edge labels, chained edges on one line, subgraphs, and quoted labels containing punctuation that would otherwise look like a second declaration.

Install

npm install @gagoar/mermaid-flowchart-parser

Usage

import { parseFlowchart, extractMermaidNodeIds } from "@gagoar/mermaid-flowchart-parser";

const { nodes, edges } = parseFlowchart(`
  flowchart TD
    api[API] -->|"HTTP"| db[(Database)]
`);
// nodes: ["api", "db"]
// edges: [{ from: "api", to: "db", arrow: "-->", label: "HTTP" }]

const ids = extractMermaidNodeIds(`flowchart TD\n  api --> db`);
// ids: Set(["api", "db"])

API

parseFlowchart(source: string): ParsedFlowchart

interface FlowchartEdge {
  from: string;
  to: string;
  arrow: string;   // raw arrow token, e.g. "-->", "-.->", "==>", "<-->"
  label?: string;
}

interface ParsedFlowchart {
  nodes: string[];       // declared node ids, in first-seen order
  edges: FlowchartEdge[];
}

extractMermaidNodeIds(source: string): Set<string>

Convenience wrapper for callers that only need the set of declared node ids.

Known limits

  • Not a full grammar: constructs outside common node-shape/arrow/subgraph syntax (e.g. class/click/style statement targets, multi-id class A,B lists) are not specially parsed. They typically don't match the node-shape pattern and are ignored, rather than misidentified.
  • Edge direction on <--> is reported as a single bidirectional arrow token, not split into two directed edges.

License

MIT