Skip to content
Latest swf2es 0.1.47

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
bounce.swf ActionScript 3

Put a SWF on your page. The packages for a page are ES modules, with no dependencies outside @swf2es/*.

One tag

Load the browser build from a CDN and give the element a SWF.

In the guide
index.html
<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
index.html
<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 guide
terminal
npm install -g @swf2es/cli
swf2es movie.swf -o movie.swf2es --emit-libraries

On 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
terminal
# a local SWF
npx @swf2es/desktop movie.swf
# one by its URL
npx @swf2es/desktop https://example.com/movie.swf
# its trace() in the terminal
npx @swf2es/desktop --trace movie.swf
# an AIR application, by its descriptor
npx @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
  1. SWF @swf2es/format

    Read in the browser: tags, shapes, bitmaps, sounds and the ActionScript bytecode in them.

  2. Compiler codegen.wasm

    Written in Zig. It parses and verifies each method, then writes it out as JavaScript.

  3. JavaScript modules

    The browser's JIT runs them. Compiled ahead of time, they come out the same.

  4. Runtime and player @swf2es/player

    AS3's object model and builtins, Flash's display list, timeline, text, sound and input.

  5. Renderer WebGL 2

    Fills, 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 runs

Ahead of Flash on all 12 AS3 benchmarks. Measured against Flash's JIT and interpreter in AIR's adl.

12 of 12 AS3 benchmarks ahead of Flash's JIT in total
1.4×–11× as fast as Flash's interpreter, AVM1 section by section
  1. String and number methods 4.03× swf2es 462 ms, Flash 1,861 ms
  2. Typed calls and new 1.92× swf2es 638 ms, Flash 1,223 ms
  3. Untyped names 1.15× swf2es 1,178 ms, Flash 1,356 ms
  4. Array and Vector natives 1.72× swf2es 549 ms, Flash 944 ms
  5. for-in and for each 1.05× swf2es 3,547 ms, Flash 3,739 ms
  6. Dictionaries 3.11× swf2es 680 ms, Flash 2,117 ms
  7. Vector and Array indexing 2.92× swf2es 1,715 ms, Flash 5,009 ms
  8. BitmapData pixels 1.21× swf2es 368 ms, Flash 446 ms
  9. The display list 3.88× swf2es 696 ms, Flash 2,697 ms
  10. 10,000 Sprites a frame 1.91× swf2es 917 ms, Flash 1,748 ms
  11. Protobuf, AMF3 and JSON 3.54× swf2es 1,600 ms, Flash 5,671 ms
  12. 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.

Play your first SWF

Open or drop one on the player. It stays in your browser.

npm install @swf2es/web