# ANN: Julia parser for JavaScript based on lezer grammar v1.0.0

**URL:** <https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760>\
**Category:** Package Announcements\
**Tags:** parser, pluto, javascript\
**Created:** [June 23, 2026, 12:17pm UTC](https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760 "2026-06-23T12:17:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [June 23, 2026, 12:17pm UTC](https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760/1 "2026-06-23T12:17:19Z")

</div>

Hi! 👋

The Pluto team is proud to announce [`@plutojl/lezer-julia`](https://github.com/JuliaPluto/lezer-julia) version 1.0! This is a parser for Julia syntax to be used in JavaScript: you can use it in web browsers, NodeJS, Bun or Deno.

Our parser is of very high quality: it parses even the most esoteric Julia code correctly, and it has a detailed parse tree, which makes pattern matching easy.

# What is a JavaScript parser for Julia?

This package gives a [`lezer`](https://lezer.codemirror.net/) grammar, which you can use to parse Julia code in JavaScript. This is useful for interactive web experiences with Julia. You can run this snippet in Deno:

```js
> import { parser } from "npm:@plutojl/lezer-julia";

> const code = `function area(r)
    return π * r^2
end`;

> const tree = parser.parse(code);

> console.log(tree.toString())
Program(FunctionDefinition(function,Signature(CallExpression(Identifier,Arguments("(",Identifier,")"))),ReturnStatement(return,BinaryExpression(Identifier,TimesOp,BinaryExpression(Identifier,PowerOp,IntegerLiteral))),end))

```

The result is a Concrete Syntax Tree (CST) of your code. You can use this `tree` object in various ways. You can walk through the tree in a [functional style](https://lezer.codemirror.net/docs/ref/#common.Tree.iterate) or an [imperative style](https://lezer.codemirror.net/docs/ref/#common.Tree.cursor). You can [query the tree at a string position](https://lezer.codemirror.net/docs/ref/#common.Tree.cursorAt), and you can make simple [queries](https://lezer.codemirror.net/docs/ref/#common.SyntaxNodeRef.matchContext).

# Incremental parsing and CodeMirror 6

Lezer grammars support [incremental parsing](https://lezer.codemirror.net/docs/ref/#common.Incremental_Parsing), which means that the syntax tree can be constructed once for a large piece of text, and then updated incrementally when you make a small change to the text, without re-parsing the complete document.

Because of this property, lezer is ideal for use in [CodeMirror 6](https://codemirror.net/), a web-based code editor using in Pluto, Jupyer, GitHub and many more sites. Our package means that CodeMirror 6 now has very good Julia support.

# Demo website

I vibe coded a demo website! Here you can see the parser side-by-side with the old regex-based CodeMirror 5 parser. At the bottom, you can click-to-expand the parse tree. [Demo site](https://juliapluto.github.io/lang-julia-demo/)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/6/66dc9ad5ce2a3989848cf29a8e05372033e03c4d.png)

# I made a PR to Jupyter! ✨

I am working on a [PR to Jupyter and JupyterLab](https://github.com/jupyterlab/jupyterlab/pull/19049) to use our parser. They already use CodeMirror 6, but for Julia they currently have a simple (unmaintained) regex-based parser. With the new parser, Jupyter would have more rich syntax highlighting for Julia, and it would add support for new Julia syntax features.

Before:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/2/a2da46fff3676d91fdf18031fc4318b93927acdf.png)

After:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/a/ca222d788a2b76b152c060a44f5a71d3c4f4b6f3.png)

# Credits

I’m posting this because I am excited about this parser, but most of the work was done by others, mainly from the Pluto team! The parser was first written by Andrey Popp. Michiel Dral and Paul Berg improved the parser for use in Pluto.jl. Sergio A. Vargas (also main contributor of [tree-sitter-julia](https://github.com/tree-sitter/tree-sitter-julia)) did a major rewrite for more complete Julia support, and a more detailed parse tree. I did some recent bug fixing with AI help.

---

<div class="post-metadata">

**Author:** ![GODBLADE](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/godblade/32/223977_2.png) [@GODBLADE](https://discourse.julialang.org/u/GODBLADE)\
**Post date:** [June 27, 2026, 7:52pm UTC](https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760/2 "2026-06-27T19:52:07Z")

</div>

wow very helpful 😃

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [July 13, 2026, 8:03pm UTC](https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760/3 "2026-07-13T20:03:09Z")

</div>

I respectfully salute everyone who contributed.

Who is crazy enough to write a new Julia interpreter using this parser? 🙂

```html
<script language="julia">
...
</script>

```

is now a possible thing 🙂

---

<div class="post-metadata">

**Author:** ![kahliburke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kahliburke/32/208472_2.png) [@kahliburke](https://discourse.julialang.org/u/kahliburke)\
**Post date:** [July 13, 2026, 9:45pm UTC](https://discourse.julialang.org/t/ann-julia-parser-for-javascript-based-on-lezer-grammar-v1-0-0/137760/4 "2026-07-13T21:45:32Z")

</div>

Yes, thanks to those who worked on this. I’ve been testing it out and it seems to work very well.
