feynjs A JavaScript engine for Feynman diagrams. Write a diagram as text; feynjs lays it out and draws it, on the web, in Markdown and in TeX. Feynman diagrams have lived in TeX: drawn in TikZ-Feynman with each vertex placed by hand, then pasted into web pages and notes as images that no longer match their source. feynjs places every vertex itself, following the conventions of published diagrams (time left to right…
A JavaScript engine for Feynman diagrams. Write a diagram as text; feynjs lays it out and
draws it, on the web, in Markdown and in TeX.
Feynman diagrams have lived in TeX: drawn in TikZ-Feynman with each vertex placed by hand, then
pasted into web pages and notes as images that no longer match their source. feynjs places every
vertex itself, following the conventions of published diagrams (time left to right; s- and
t-channels, cascades, loops and hadrons as papers draw them), and each particle sets its own line,
arrow and label. Because it is JavaScript, the browser draws the diagram as SVG in the page, in the
page’s colours; the same source gives TikZ-Feynman code for a paper.
Write every line, as in TikZ-Feynman:
i1 [e-] -- a -- i2 [e+]
a -- [gamma] b
f1 [mu-] -- b -- f2 [mu+]
or name the process and its decays, as in MadGraph:
A Markdown site (Zensical, MkDocs): the script, and feynman blocks passed through as they are:
[project]
extra_javascript = ["https://cdn.jsdelivr.net/npm/[email protected]/dist/feynjs.min.js"]
[project.markdown_extensions]
pymdownx.superfences.custom_fences = [
{ name = "feynman", class = "feynman", format = "pymdownx.superfences.fence_div_format" },
]
Obsidian. Unzip feynjs-obsidian.zip from the
latest release into your vault’s
.obsidian/plugins/; feynman blocks draw in your notes.
LaTeX. Write diagrams in a document with the feynjs package;
feynjs cache writes each as TikZ-Feynman code with every vertex placed, so the document compiles
anywhere TikZ-Feynman does, Overleaf and arXiv included.
\usepackage{feynjs}
\begin{feynjs}
p p > t tbar
\end{feynjs}
MadGraph. Drop feynjs-madgraph.zip from the
latest release into MadGraph’s PLUGIN
directory; mg5_aMC --mode=feynjs, then feynjs DIR, draws every diagram of a process.
What it draws
Diagrams from lines or processes: loops ({t}), production modes (ggF, VBF, VBS),
decays in place (W+(> e+ ve)), panels side by side.
Particles by name, TikZ-Feynman and MadGraph alike (t~, ve, W+): line style, arrow,
label and properties follow; supersymmetric particles in colour.
Hadrons as ellipses, braces or caps, quarks inside with their colour flux tubes, and
nuclei from hydrogen to lead.
Colour flow, charge colour, and detector objects: jets, large-R jets with their
contents, taus, missing energy, semi-visible and emerging jets.
Layouts: a force layout by default, a grid, and points placed by hand as in TikZ;
debug: on shows which rules place each line.
Views: the event in the detector (transverse or longitudinal), and the lattice.
Output: SVG, PNG, and TikZ-Feynman code; every part of the SVG named, and the diagram
embedded as data.
The same diagram everywhere
The layout is a balance of forces, reviewed figure by figure against the Feynman diagrams of ATLAS
public results (validation/). Every approved layout is recorded, and the tests fail
if one moves without being approved again. The layout uses its own portable maths, so a diagram
comes out bit for bit the same on every processor and in every JavaScript engine; a
workflow checks this on Linux, macOS and Windows, x86 and ARM,
and in Chromium, Firefox and WebKit.
Develop
npm ci
npm run typecheck && npm run build && npm test
npm run docs # the docs site into site/ (needs `pip install -r requirements-docs.txt`)
If feynjs helps your work, please cite it. Every release is archived on Zenodo with a DOI of its
own; 10.5281/zenodo.24497761 always resolves to the
latest.
@software{feynjs,
author = {Oliver, Jason and Zhu, Pengxuan},
title = {feynjs: a JavaScript engine for Feynman diagrams},
version = {0.10.3},
year = {2026},
doi = {10.5281/zenodo.24497761},
url = {https://github.com/hepjs/feynjs}
}
CITATION.cff has the same details (GitHub’s Cite this repository button reads
it). A paper describing feynjs is in preparation.
评论