HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
WebAssembly
binaryen
WebAssembly2015–2026
WebAssembly / binaryen

binaryen

Optimizer and compiler/toolchain library for WebAssembly

27Distinct people
37Mentions
0Explicit recommenders
8.7KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Optimizer and compiler/toolchain library for WebAssembly

GitHub

Where it is used

  • aurora-engine — For WebAssembly optimization we use wasm-opt from the Binaryen toolchain for WebAssembly. Source

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 11:56:56 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year37 dated mentions

Observed mentions: 2015-12-17 19:33:40 UTC to 2026-03-14 15:34:22 UTC.

02468102015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 9 mentions; 0 submissions, 9 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC312
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC909
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC404
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC505
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC202
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC303
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC303
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC202
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC303
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
Binaryen Binaryen is a compiler and toolchain infrastructure library for WebAssembly, written in C++. It aims to make compiling to WebAssembly easy, fast, and effective: Easy: Binaryen has a simple C API in a single header, and can also be used from JavaScript. It accepts input in WebAssembly-like form but also accepts a general control flow graph for compilers that prefer that. Fast: Binaryen's internal IR uses compact data structures and is designed for completely parallel codegen and optimization, using all available CPU cores. Binaryen's IR also compiles down to WebAssembly extremely easily and quickly because it is essentially a subset of WebAssembly. Effective: Binaryen's optimizer has many passes (see an overview later down) that can improve code size and speed. These optimizations aim to make Binaryen powerful enough to be used as a compiler backend by itself. One specific area of focus is on WebAssembly-specific optimizations (that general-purpose compilers might not do), which you can think of as wasm minification, similar to minification for JavaScript, CSS, etc., all of which are language-specific. Toolchains using Binaryen as a component (typically running wasm-opt) include: Emscripten (C/C++) wasm-pack (Rust) J2CL (Java; J2Wasm) Kotlin (Kotlin/Wasm) Dart (Flutter) wasm_of_ocaml (OCaml) For more on how some of those work, see the toolchain architecture parts of the V8 WasmGC porting blogpost. Compilers using Binaryen as a library include: AssemblyScript which compiles a variant of TypeScript to WebAssembly wasm2js which compiles WebAssembly to JS Asterius which compiles Haskell to WebAssembly Grain which compiles Grain to WebAssembly Binaryen also provides a set of toolchain utilities that can Parse and emit WebAssembly. In particular this lets you load WebAssembly, optimize it using Binaryen, and re-emit it, thus implementing a wasm-to-wasm optimizer in a single command. Interpret WebAssembly as well as run the WebAssembly spec tests. Integrate with Emscripten in order to provide a complete compiler toolchain from C and C++ to WebAssembly. Polyfill WebAssembly by running it in the interpreter compiled to JavaScript, if the browser does not yet have native support (useful for testing). Consult the contributing instructions if you're interested in participating. Binaryen IR Binaryen's internal IR is designed to be Flexible and fast for optimization. As close as possible to WebAssembly so it is simple and fast to convert it to and from WebAssembly. There are a few differences between Binaryen IR and the WebAssembly language: Tree structure Binaryen IR is a tree, i.e., it has hierarchical structure, for convenience of optimization. This differs from the WebAssembly binary format which is a stack machine. Binaryen uses Stack IR to optimize "stacky" code (that can't be represented in structured form). When stacky code must be represented in Binaryen IR, such as with multivalue instructions and blocks, it is represented with tuple types that do not exist in the WebAssembly language. In addition to multivalue instructions, locals and globals can also have tuple types in Binaryen IR but not in WebAssembly. Experiments show that better support for multivalue could enable useful but small code size savings of 1-3%, so it has not been worth changing the core IR structure to support it better. Block input values (currently only supported in catch blocks in the exception handling feature) are represented as pop subexpressions. pops must appear as the first instruction in a catch block (ignoring unnamed blocks around them, as those are not emitted in the binary format). Types and unreachable code WebAssembly limits block/if/loop types to none and the concrete value types (i32, i64, f32, f64). Binaryen IR has an unreachable type, and it allows block/if/loop to take it, allowing local transforms that don't need to know the global context. As a result, Binaryen's default text output is not necessarily valid wasm text. (To get valid wasm text, you can do --generate-stack-ir --print-stack-ir, which prints Stack IR, this is guaranteed to be valid for wasm parsers.) Binaryen supports a stringref type. This is similar to the currently- inactive stringref proposal, with the difference that the string type is a subtype of externref rather than anyref. Doing so allows toolchains to emit code in a form that uses js string builtins which Binaryen can then "lift" into stringref in its internal IR, optimize (for example, a concatenation of "a" and "b" can be optimized at compile time to "ab"), and then "lower" that into js string builtins once more. Blocks Binaryen IR has only one control flow structure that contains a variable-length list of children: the block. WebAssembly on the other hand allows all control flow structures, such as loops, if arms, and function bodies, to have multiple children. In Binaryen IR, these other control flow structures have a single child. This child may of course be a block. The motivation for this property is that many passes need special code for iterating on lists of instructions, so having a single IR node with a list simplifies them. As in the Wasm text format, blocks and loops may have names. Branch targets in the IR are resolved by name (as opposed to nesting depth). This has 2 consequences: Blocks without names may not be branch targets. Names are required to be unique. (Reading .wat files with duplicate names is supported; the names are modified when the IR is constructed). As an optimization, a block with no name, which can never be a branch target, will not be emitted when generating wasm. Instead its list of children will be directly used in the containing control flow structure. Such a block is sometimes called an "implicit block". Reference Types The wasm text and binary formats require that a function whose address is taken by ref.func must be either in the table, or declared via an (elem declare fun
Read the full README on GitHub

What Hacker News says

37 sources
Andy jests, but I would actually like to add nominal types to Wasm (along with type imports to make them usable). No proposal yet, but maybe later this year. This blog post mentions that you can kind of emulate nominal types by putting all your types in one rec group, but then it brushes that off as inferior to using exceptions. (Which is hilarious! Good work, Andy.) What it doesn’t make clear is that people actually use this rec group trick in practice. There are two ways to do it: you can put literally all your types in one rec group, or you can emit minimal rec groups with additional “brand types” that serve no purpose but to ensure the groups have different structures. The former solution is better for code size when the entire application is one module, but the latter solution is better if there are multiple modules involved. You don
Read the rest
’t want to repeat every type definition in every module, and using smaller rec groups lets you define only the types that are (transitively) used in each module. The Binaryen optimizer has to ensure that it does not accidentally give distinct types the same structural identity because that would generally be observable by casts. Most of its type optimizations therefore put all the types in one rec group. However, it does have a type merging optimization that takes the casts into account[0]. That optimization is fun because it reuses the DFA minimization code from the original equirecursive type system we were experimenting with for Wasm GC. We also have a rec group minimization optimization[1] that creates minimal rec groups (by finding strongly connected components of the type definition graph), then ensures the types remain distinct first by using different permutations of the types within a rec group and then only as necessary by adding brand types. [0]: https://github.com/WebAssembly/binaryen/blob/main/src/passes... [1]: https://github.com/WebAssembly/binaryen/blob/main/src/passes...
In Nominal Types in WebAssembly
Validation errors were bit of an issue. Especially because Binaryen constructs an internal IR that remains opaque until we emit the Wasm text. I did consider Wizard for my project but settled on Wasmtime because I needed WASI support. My major pain point was the documentation. The binaryen.js API reference¹ is a list of function signatures. Maybe this makes sense to someone more experienced but I found it hard to understand initially. There are no explanation of what the parameters mean. For example, the following is the only information the reference provides for compiling an `if` statement: Module#if(condition: Expression, ifTrue: Expression, ifFalse?: Expression): Expression In contrast, the Wasm instruction reference on MDN² is amazing. WASI again suffers from the same documentation issues. I didn't find any official resource on ho
Read the rest
w to use `fd_write` for example. Thankfully I found this blog post³. Wasm feels more inaccessible that other projects. The everyday programmer shouldn't be expected to understand PL research topics when they are trying to do something with it. I understand that's not the intention but this is what it feels like. 1. https://github.com/WebAssembly/binaryen/wiki/binaryen.js-API 2. https://developer.mozilla.org/en-US/docs/WebAssembly/Referen... 3. https://tty4.dev/development/wasi-load-fd-write/
In WASM 3.0 Completed
This is indeed unfortunate, but on the other hand, multivalue's benefits are probably very small. Inside functions, there is perhaps a 1-3% code size opportunity at best (https://github.com/WebAssembly/binaryen?tab=readme-ov-file#b...), and no performance advantage. Between functions there might be a performance advantage, but as wasm VMs do more things like runtime inlining (which becomes more and more important with wasm GC and the languages that compile to it), that benefit goes away.
In WASM 2.0
I'm not sure there is a clear separation between applying heuristics and searching a space. Often in compilers you search a subset of a space using heuristics, and you can adjust those to control how much of the space you cover. For example, here is a pass that reorders WebAssembly globals in the Binaryen optimizer: https://github.com/WebAssembly/binaryen/blob/main/src/passes... We have a simple criteria for the quality of a solution - how big the binary size is with an order - but the space of possible orders is huge (every permutation that keeps every global after its dependencies). What we do is a targeted search of that space using some heuristics using parameters that work well enough and aren't too slow in practice.
In Beating the Compiler
More things that I've found helped: - Use wasm-opt from binaryen. That seems to reliably drop wasm size by ~20-30%. ( https://github.com/WebAssembly/binaryen ) - Use brotli compression for serving wasm bundles to the browser, and make sure your web server is setup to use the brotli compressed files. (Its a 1 line change in nginx, for example). Brotli drops the size of wasm bundles by about 3x. Its much better than gzip for wasm.
In Tree-shaking, the horticulturally misguided algorithm (2023)
Interesting article, thanks! Notes on the issues mentioned there: * The need for a manual shadow stack: This is fixed in WasmGC (in the same way it works in JS, as the link mentions). * Lack of try-catch: This is fixed by the Wasm exception handling proposal, which has already shipped in browsers, https://github.com/WebAssembly/exception-handling/blob/main/... * Null checks: Mostly fixed by WasmGC. The spec defines non-nullable local types, and VMs can use the techniques the article mentions to optimize them using signals (Wizard does, for example). * Class initialization: This is a difficult problem, as the article says. J2Wasm and Binaryen are working to optimize it through static analysis at the toolchain level. Here is a recent PR I wrote that makes progress there: https://github.com/WebAssembly/binaryen/pull/6061 * The vtable overhea
Read the rest
d issue the article mentions may be a problem. I'm not aware of good measurements on it, through. There are some ideas on post-MVP solutions for method dispatch that might help, but nothing concrete yet. * Checks for null and trapping: There has been discussion of variants on the GC instructions that throw instead of trap. Measurements, however, have not shown it to be a big problem atm, so it is low priority. The author is right that stack walking, signals, and memory control are important areas that could help here. Overall with WasmGC and exceptions we are in a pretty good place for Java as emitted by J2Wasm today: it is usually faster than J2CL which compiles Java to JavaScript. But there is definitely room for improvement.
In Bringing garbage collected programming languages efficiently to WebAssembly
The end of the related work section cites both wasm-smith and the Binaryen fuzzer (https://github.com/WebAssembly/binaryen/wiki/Fuzzing) and says, "They both provide a fuzzer that turns a stream of bytes into a WebAssembly module in order to test implementations. Their fuzzers always generate semantically valid test cases, but lack the targeting and tuning that Xsmith provides." I look forward to reading more about how they do the targeting and tuning.
In Random Testing of WebAssembly Implementations Using Semantically Valid Programs
This is a slim alternative to Emscripten which focuses only on the C/C++ <=> JS interoperability part: https://github.com/schellingb/wajic I don't think there are actual Emscripten replacements though which give you all the features, but in a 'cleaner' package. Emscripten does a lot on top of clang/llvm. A lot of the 'Emscripten magic' has been moved into the Binaryen tools though, so it can be used by other toolchains (like wajic): https://github.com/WebAssembly/binaryen.
In CoWasm: An alternative to Emscripten, based on Zig (demo: Python in the browser)
The binaryen toolkit comes with a wasm2js tool, you could translate the wasm back to js and see how performance compares ;) It's possible that performance isn't all that different, because asm.js-style Javascript can be surprisingly fast (compared to "idiomatic" human-written Javascript). Otherwise it's a completely pointless excercise of course, unless you need to support browsers without WASM support (which don't exist anymore AFAIK). [1] https://github.com/WebAssembly/binaryen
In Migrating a JavaScript Library from JavaScript to WebAssembly

Showing the 15 most recent of 37 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.