Cross-browser Javascript library for drawing Feynman diagrams using SVG and HTML5, based on feynMF
JavaScript CSS HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Cross-browser Javascript library for drawing Feynman diagrams using SVG and HTML5, based on feynMF [1].

alt tag

See more examples


The library is by no means ready yet to be used in "production". Check out jQuery.feyn [2] for a reliable HTML5 solution.



  • SVG.js - for now, see roadmap

###Latex (feynMF) flavour example


<div id="annihilation"></div>
<script src="../path/to/svg.min.js"></script>
<script src="../path/to/svg.foreign.js"></script>
<script src="../path/to/feynman.min.js"></script>


var feynman = new Feynman();

var annihilation = {
  title      : 'Electron-Positron Annihilation',
  width      : 400,
  height     : 400,
  showAxes   : true,
  lang       : 'latex',
  diagram    : [

feynman.draw("annihilation", annihilation);

More examples.



The library is based on feynMF [1] and it implements most of its features including the auto-layout system. Given a simple instruction set and description of participants in a system the engine will attempt to lay out the diagram as nicely as possible without any manual intervention. Currently there is no option to position elements by hand but it is top priority.


The library allows easy implementation of different parser engines through a unified stage class. At the moment only the feynMF language is supported.


Experimental. The current label positioning function is dodgy, there is too many variables to calculate with and MathJax is unreliable. However it places labels good enough so that they can be fine tuned by hand using the labelx and labely attributes (see examples).


  • Add more line types e.g.: dashed, dotted
  • Add more vertex types, i.e.: blobs
  • Implement API to allow after-draw handling of elements (i.e.: fine tuning position of vertices, propagators etc.)
  • Remove svg.js dependency
  • Add support for non MathJax labels (i.e.: unicode labels)
  • Add option to turn off auto-layout and allow users to position elements through configuration
  • Animations: for educational purposes, to help easier understanding of particle behaviour



To submit a fix or an enhancement fork the repository, checkout the 'development' branch, add your name to the Contributors section in, and send a pull request!


Install dependencies first:

npm install

Then run build task:


Generated files can be found in the dist folder.

###Running unit tests

To run test suite from command line type:

grunt test

Alternatively you can run it in the browser at /spec. There is also a grunt task with live reload:

grunt watch:test




This software is licensed under the MIT License.