Skip to content

What it does

  • ECMAScript 2025 scripts and modules, with a span on every node.
  • ESTree JSON out, the same trees acorn gives on every source in the benchmark.
  • Scopes, bindings, free variables, imports and exports, and the early errors the spec requires.
  • Diagnostics with codes, labels and code frames, and every error in one parse.
  • Incremental parsing: after an edit, it reparses what the edit touched.
  • Page state read straight from the literals in a page’s scripts, Next.js payloads and JSON in a script included.
  • A depth limit, a step budget and an input cap, so a hostile script fails fast instead of overflowing the stack.

Add it

In Rust, add parsec-js (0.3.1 on crates.io); the library inside isparsec_js. Parsing and page state work from Python, JavaScript and C as well.

parsec-js 0.3.1, from its documentation
use parsec_js::{Node, parse_script};

let src = "const total = items.reduce((sum, x) => sum + x, 0);";
let ast = parse_script(src).unwrap();
let Node::Program { body, .. } = *ast.node(ast.root()) else { unreachable!() };
let first = ast.get(body)[0];
assert_eq!(ast.span(first).text(src), src);
assert!(ast.to_estree(src).contains(r#""type":"ArrowFunctionExpression""#));

That's the first example in the crate's own documentation at the v0.3.1 tag, unchanged.cargo test runs it on every change, so it compiles and passes against the release you'd install. The API reference on docs.rs has the rest, and the getting started guide goes step by step.

Checked against the standards

These counts are the conformance baseline on Parsec's main branch, read when this page was built. Each release has to match or beat them: a suite that passes fewer cases, or fails more, stops the release.

SuitePassFailSkipped
test262, parsing52,78201,313

Standards has every suite, where its data comes from, and why the failures and skips are what they are.

Where it stops

  • It never runs code, and never will. State a script builds at run time isn’t there to read.
  • On the smallest inline scripts it’s still behind oxc_parser, by about a quarter of a microsecond a script. Closing that changes the public Token type, so it waits for 0.4.0.

The JavaScript page in the docs goes through the API, the limits and the conformance details in full.