Flash, compiled
to JavaScript
Play SWF files in the browser, ActionScript 1, 2 and 3 alike, with no plug-in. A SWF you open is read in your browser, never uploaded.
Flash, running again. ActionScript 1, 2 and 3 compiled to JavaScript, with Flash Player's APIs on top, each checked against Flash.
ActionScript
- ActionScript 3
- Compiled to JavaScript as the SWF loads, so the browser's JIT runs it. Checked against avmshell on Tamarin's tests.
- ActionScript 1 and 2
- AVM1's timelines, clips, buttons, text fields and loads, compiled to JavaScript too.
- Ahead of time
- The swf2es command compiles a SWF before you ship it, to the same code the browser would make.
- Your files stay with you
- Open or drop a SWF on the player and it is read in your browser. Nothing is uploaded.
The player
- Display list and timeline
- Shapes, morphs, masks and frames, drawn by a WebGL 2 renderer of its own.
- Text and bitmaps
- Text fields in device and embedded fonts, and BitmapData with its filters.
- Filters and blend modes
- Blurs, glows, shadows and the rest, with Flash's blend modes and Pixel Bender.
- Sound and input
- MP3 and the sound APIs, the keyboard and the mouse.
Beyond the stage
- Workers
- Flash Workers on threads of their own, sharing memory and Mutexes.
- ExternalInterface
- Calls both ways between the SWF and the page's JavaScript.
- Stage3D
- Context3D and AGAL on WebGL, ATF textures included.
- The desktop
- A SWF in a window of its own, with sockets and files.
See it run. Bounce is an ActionScript 3 SWF built from the repository's source, compiled as this page plays it.
Click to add balls.
Space pauses. Gradients, glow filters and additive blending, drawn with WebGL 2.
Open it in the player
Put a SWF on your page.
The packages for a page are ES modules, with no dependencies outside @swf2es/*.
<script type="module" src="https://unpkg.com/swf2es@0.1.47"></script>
<swf2es-player src="movie.swf" width="800" height="600"></swf2es-player>Old Flash tags
Play the object and embed tags a page already has, SWFObject's included.
In the guide<script src="https://unpkg.com/swf2es@0.1.47/dist/plugin.js" crossorigin></script><script src="swfobject.js"></script>
<script type="module"> import { watchFlash } from "https://unpkg.com/swf2es@0.1.47";
watchFlash();</script>Ahead of time
Compile a SWF's ActionScript before you ship it, and serve the modules beside it.
In the guidenpm install -g @swf2es/cliswf2es movie.swf -o movie.swf2es --emit-librariesOn the desktop
Play a SWF from a file or a URL, or an AIR application, in a window of its own, with sockets and files.
In the guide# a local SWFnpx @swf2es/desktop movie.swf# one by its URLnpx @swf2es/desktop https://example.com/movie.swf# its trace() in the terminalnpx @swf2es/desktop --trace movie.swf# an AIR application, by its descriptornpx @swf2es/desktop app.xml
From SWF to JavaScript.
The same compiler runs in the page as a SWF loads and in the swf2es command.
The architecture notes
-
SWF
@swf2es/formatRead in the browser: tags, shapes, bitmaps, sounds and the ActionScript bytecode in them.
-
Compiler
codegen.wasmWritten in Zig. It parses and verifies each method, then writes it out as JavaScript.
-
JavaScript
modulesThe browser's JIT runs them. Compiled ahead of time, they come out the same.
-
Runtime and player
@swf2es/playerAS3's object model and builtins, Flash's display list, timeline, text, sound and input.
-
Renderer
WebGL 2Fills, strokes, filters, blend modes and masks drawn by its own renderer, and Stage3D on top.
How much of Flash runs. Worked out from the repository's tests each time the site builds.
Video streams and printing are not there yet, and some SWFs still draw or behave differently.
See what runsAhead of Flash on all 12 AS3 benchmarks. Measured against Flash's JIT and interpreter in AIR's adl.
- String and number methods 4.03× swf2es 462 ms, Flash 1,861 ms
- Typed calls and new 1.92× swf2es 638 ms, Flash 1,223 ms
- Untyped names 1.15× swf2es 1,178 ms, Flash 1,356 ms
- Array and Vector natives 1.72× swf2es 549 ms, Flash 944 ms
- for-in and for each 1.05× swf2es 3,547 ms, Flash 3,739 ms
- Dictionaries 3.11× swf2es 680 ms, Flash 2,117 ms
- Vector and Array indexing 2.92× swf2es 1,715 ms, Flash 5,009 ms
- BitmapData pixels 1.21× swf2es 368 ms, Flash 446 ms
- The display list 3.88× swf2es 696 ms, Flash 2,697 ms
- 10,000 Sprites a frame 1.91× swf2es 917 ms, Flash 1,748 ms
- Protobuf, AMF3 and JSON 3.54× swf2es 1,600 ms, Flash 5,671 ms
- LZ4 by Crossbridge 1.54× swf2es 693 ms, Flash 1,064 ms
Time taken, shorter is faster; the figure is Flash's time over swf2es'. Medians of 5 runs, 2026-12-04, i9-13900H, Chrome 158 (SwiftShader), AIR 51.5.1's adl under Wine. Within these totals, 32 sections are still behind Flash. docs/benchmarks.md lists every section and how to run them yourself.
- int-arith 4.2× swf2es 110 ms, Flash 459 ms
- number-arith 4.3× swf2es 118 ms, Flash 505 ms
- math-calls 4.1× swf2es 195 ms, Flash 790 ms
- string-concat 11× swf2es 38 ms, Flash 418 ms
- int-arith-timeline 7.9× swf2es 89 ms, Flash 703 ms
- object-named 6.1× swf2es 112 ms, Flash 682 ms
- object-keyed 6.2× swf2es 107 ms, Flash 660 ms
- array-read 5.8× swf2es 28 ms, Flash 163 ms
- array-write 8.1× swf2es 29 ms, Flash 234 ms
- array-push-pop 4.9× swf2es 48 ms, Flash 233 ms
- for-in 5.3× swf2es 27 ms, Flash 142 ms
- function-call 6.2× swf2es 85 ms, Flash 524 ms
- method-call 5.4× swf2es 186 ms, Flash 998 ms
- inherited-call 5.3× swf2es 185 ms, Flash 983 ms
- construct 4.2× swf2es 200 ms, Flash 847 ms
- call-apply 4.8× swf2es 177 ms, Flash 857 ms
- timeline-vars 5.7× swf2es 95 ms, Flash 544 ms
- with-object 5.9× swf2es 74 ms, Flash 433 ms
- with-clip 4.9× swf2es 74 ms, Flash 362 ms
- root-paths 4.4× swf2es 69 ms, Flash 302 ms
- parent-paths 4× swf2es 69 ms, Flash 279 ms
- eval-set 3.5× swf2es 110 ms, Flash 388 ms
- attach-remove 1.4× swf2es 111 ms, Flash 155 ms
- duplicate-remove 1.5× swf2es 93 ms, Flash 140 ms
- create-remove 1.5× swf2es 85 ms, Flash 127 ms
- enterframe-script 4.3× swf2es 84 ms, Flash 358 ms
- enterframe-display 2.4× swf2es 292 ms, Flash 713 ms
Time taken, shorter is faster; the figure is Flash's time over swf2es'. Medians of 5 runs, 2026-12-04, i9-13900H, Chrome 158 (SwiftShader), AIR 51.5.1's adl under Wine. docs/benchmarks.md lists every section and how to run them yourself.
Play your first SWF
Open or drop one on the player. It stays in your browser.
npm install @swf2es/web