
Boa is an experimental JavaScript lexer, parser, and interpreter written in Rust 🦀, supported by More Over 90% of the latest ECMAScript specification. We continually improve conformance to keep up with the ever-evolving standards.
Try the engine now in the live WASM playground here!
Prefer CLI? feel free to try boa_cli,
Boa currently publishes and actively maintains the following crates:
boa_ast– Boa’s ECMAScript abstract syntax treeboa_cli– CLI and REPL implementation of Boaboa_engine– Boa’s implementation and execution of ECMAScript created objectsboa_gc– Boa’s garbage collectorboa_interner– Boa’s String Internerboa_parser– Boa’s lexer and parserboa_icu_provider– Boa’s ICU4X data providerboa_runtime– Boa’s WebAPI featuresboa_string– Boa’s ECMAScript string implementation.tag_ptr– Utility library that enables a pointer to be associated with a tag of some typeusize,
Comment
Boa And boa_unicode Crates are deprecated.
Just add this to start using Boa boa_engine crate for you Cargo.toml,
[dependencies]
boa_engine = "0.21.0"
then in main.rsCopy below:
use boa_engine::{Context, Source, JsResult};
fn main() -> JsResult<()> {
let js_code = r#"
let two = 1 + 1;
let definitely_not_four = two + "2";
definitely_not_four
"#;
// Instantiate the execution context
let mut context = Context::default();
// Parse the source code
let result = context.eval(Source::from_bytes(js_code))?;
println!("{}", result.display());
Ok(())
}
Now, all that’s left to do is cargo run,
Congrats! You have executed your first JavaScript code using Boa!
For more information on the Boa API, feel free to check out our documentation.
API Documentation
To know more information about the compatibility of Boa around single script Specification, you can check our ECMAScript Test262 Test suite results here.
Please, check out the CONTRIBUTING.md file to learn how to contribute to the project. You will need Rust installed and an editor. We have some configurations ready for VSCode.
Check debugging.md for more information on debugging.
Important
This only applies to wasm32-unknown-unknown Target,
WASI And Emscripten Target variants are handled automatically.
- enable
jsFeature flag. - set
RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
rustflags can also be set by adding .cargo/config.toml File in project root directory:
[target.wasm32-unknown-unknown]
rustflags = '--cfg getrandom_backend="wasm_js"'
For more information see: getrandom WebAssembly support
- Clone this repo.
- run with
cargo run -- test.jswhere in the project root directorytest.jsis the path to an existing JS file with any valid JS code. - If any JS doesn’t work it’s a bug. Please raise an issue!

Usage: boa [OPTIONS] [FILE]...
Arguments:
[FILE]... The JavaScript file(s) to be evaluated
Options:
--strict Run in strict mode
-a, --dump-ast [] Dump the AST to stdout with the given format [possible values: debug, json, json-pretty]
-t, --trace Dump the AST to stdout with the given format
--vi Use vi mode in the REPL
-O, --optimize
--optimizer-statistics
--flowgraph [] Generate instruction flowgraph. Default is Graphviz [possible values: graphviz, mermaid]
--flowgraph-direction Specifies the direction of the flowgraph. Default is top-top-bottom [possible values: top-to-bottom, bottom-to-top, left-to-right, right-to-left]
--debug-object Inject debugging object `$boa`
-m, --module Treats the input files as modules
-r, --root Root path from where the module resolver will try to load the modules [default: .]
-h, --help Print help (see more with '--help')
-V, --version Print version
View milestones.
The current benchmarks are taken from the benchmarks for v8 which you can find here. You can also see the results of a nightly benchmark run comparing Boa with other JavaScript engines here.
If you want to run the benchmark locally, run Boa in Release combined.js Script that includes all sub-benchmarks bench-v8 Directory.
cargo run --release -p boa_cli -- bench-v8/combined.js
tip
If you want to run only a subset of the benchmarks, you can modify Makefile located in bench-v8 Directory. Comment out the benchmarks you don’t want to include, then run makeAfter that, you can run boa using the same commands above,
View profiling.
See CHANGELOG.md.
If you have any questions please feel free to contact us at Matrix. Contributor discussions take place on the same Matrix space if you’re interested in contributing. We also have discord for any question or issue.
This project is licensed under the Unlicensed or the MIT License, at your option.