Skip to content
Latchkey

wasm-strip: Remove Custom Sections from Wasm

wasm-strip removes custom sections (name, debug, producers) from a wasm module in place, reducing its size.

A last-mile size step. After optimizing with wasm-opt, wasm-strip drops the name and debug sections that ship no runtime behavior, trimming bytes off the artifact you publish.

What it does

wasm-strip rewrites the module in place, deleting custom sections (such as the name section and DWARF debug info) while keeping all functional sections intact. There is no separate output flag; it edits the file given.

Common usage

Terminal
wasm-strip module.wasm
# measure the savings
ls -l module.wasm && wasm-strip module.wasm && ls -l module.wasm

Options

FlagWhat it does
<file>The module to strip in place (required)
(no -o)wasm-strip edits the file directly; copy first if you need the original

In CI

Run wasm-strip only on the final published artifact, after any tests that rely on the name section for readable stack traces. Because it edits in place, operate on a copy if a later step (like source-map generation) still needs the debug info. Alternatively wasm-opt --strip-debug does the same during optimization.

Common errors in CI

"error: magic mismatch" means the file is not wasm. Because it writes in place, a read-only working directory yields "unable to write"; strip a writable copy in a temp path. Stripping the name section makes later stack traces show numeric indices instead of function names.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →