Try the browser editor at abetlen.github.io/pikchr-js.
What is Pikchr? From the official documentation:
Pikchr (pronounced "picture") is a PIC-like markup language for diagrams in technical documentation.
Pikchr.js allows you to turn Pikchr markup into svg diagrams directly in your browser.
npm install pikchr-js<div id="diagram"></div>
<script src="https://unpkg.com/pikchr-js"></script>
<script>
async function main() {
const pikchr = await loadPikchr();
document.getElementById("diagram").innerHTML = pikchr("box");
}
main();
</script>const loadPikchr = require("pikchr-js");
async function main() {
const pikchr = await loadPikchr();
const svg = pikchr("box");
const result = pikchr.render("box");
const darkSvg = pikchr("box", "pikchr", pikchr.flags.DARK_MODE);
console.log(svg);
console.log(result.width, result.height);
console.log(darkSvg);
}
main();Run the bundled pikchr binary via npx or bunx.
npx pikchr-js -div-center diagram.pikchr diagram.svgbunx pikchr-js -dark diagram.pikchr > diagram.svgecho "box" | npx pikchr-js -src -div - > diagram.svgThe CLI syntax is identical to upstream pikchr: pikchr [options] ?INFILE? ?OUTFILE?.
Supported options are -dark, -src, -div, -div-indent, -div-center, -div-left, -div-right, -div-toggle, and -div-source.
Input and output filenames default to stdin and stdout, and - can be used to force either side.
This Pikchr source:
box "Pikchr" fit fill white
arrow
box "SVG" fit fill whiterenders as:
See the Pikchr user manual for the full markup reference.
Use pull request titles in the form <tag>: <title>, with an optional scope when it adds clarity.
Prefer tags such as feat, fix, chore, ci, docs, and refactor.
Add changelog entries under ## [Unreleased] using the pull request title followed by by @contributor in #1234.
- feat: add support for X by @contributor in #1234
- fix(ci): repair Y build by @contributor in #1234This repository publishes npm releases from the publish.yml GitHub Actions workflow when a GitHub Release is published.
Configure npm Trusted Publishing for pikchr-js before publishing a release.
Use these values in the npm package settings:
- Publisher: GitHub Actions
- Organization or user:
abetlen - Repository:
pikchr-js - Workflow filename:
publish.yml - Environment name:
npm-publish - Allowed action:
npm publish
Create a GitHub environment named npm-publish and add required reviewers if you want manual approval before npm receives the OIDC publish request.
Trusted Publishing requires GitHub-hosted runners, and the workflow uses Node.js 24 so the npm CLI supports OIDC authentication.
For each release, merge a release PR that updates package.json, package-lock.json, and CHANGELOG.md, then create and publish a GitHub Release whose tag exactly matches the package version in vX.Y.Z form.
The publish workflow verifies the tag against package.json, installs dependencies without a package-manager cache, runs tests, checks the tarball contents, and runs npm publish without an NPM_TOKEN secret.
The static browser editor lives in site/.
Run npm run site:build to build the _site/ artifact locally.
The pages.yml workflow deploys the built site from pushes to main.
- Download the latest source archive of
pikchr - Extract the archive outside this repository
- In the extracted
pikchrsource directory, runmake pikchr.c - Copy the generated
pikchr.cinto this repository - Run
npm run buildto regeneratepikchr.jswith the pinned Dockerized Emscripten 5.0.7 build - Run
npm test
The Docker image is pinned so regenerated wasm output does not drift when new Emscripten releases are published.
If upstream Pikchr changes its SVG output, update the test fixture in test.js to match the new generated output.
This project is licensed under the 0BSD license.