WasmCoffee: In-Browser WebAssembly Compiler with Java-Inspired Syntax
WasmCoffee compiles code written with Java-inspired syntax directly to
WebAssembly (Wasm-GC)
entirely inside your browser, then executes the freshly compiled wasm on the same page. Write code using familiar
Java syntax
and compile it to WebAssembly with no backend server, no JVM or JDK to install, and no remote compilation queue.
The compiler itself is an
independent WebAssembly module written in the Odin programming
language and compiled to js_wasm32.
Write code in the editor above using Java-inspired syntax, click Run, and your program compiles off-thread in a dedicated Web Worker and runs instantly in WebAssembly with console output, HTML5 2D Canvas rendering, and event callbacks.
What You Can Do
- In-Browser Compilation — The code editor, compiler, and execution engine are all hosted on this page. Your code never leaves the tab.
- Off-Thread Web Worker — Compilation runs inside a background Worker thread, ensuring the editor, typing, and 60 FPS canvas animations never drop a frame.
- Native Wasm-GC Execution — Emits modern WebAssembly Garbage Collection opcodes
(
struct.new,array.new_data,ref.test), running on the browser's native garbage collector with peak performance. - HTML5 2D Canvas Graphics — Build interactive visual simulations, animations, and arcade games
through the pinned
Webbridge (byId,getContext,setFillStyle,arc,fillText,requestFrame). - Console & Output Logging — Interactive terminal supporting
System.out.println, arithmetic expressions, formatted loops, and string concatenation. - Object-Oriented Architecture — Complete support for classes, abstract classes, interfaces,
inheritance (
extends), dynamic method dispatch, and polymorphism. - Export Compiled .wasm — Download the compiled standalone WebAssembly binary with a single click.
How It Works
When you click Run, the IDE sends your source code to a dedicated Web Worker hosting
wasmcoffee.wasm. The worker writes the source text into the compiler's linear memory buffer and
executes the compiler pipeline — lexing, parsing, semantic analysis, type checking, and WebAssembly GC emission.
Upon completion, the compiled .wasm bytes are transferred back to the main thread and instantiated
via WebAssembly.instantiate() with two import namespaces:
wasmcoffee_env: Implements console sinks (console_str,console_i32, etc.) and 16 high-performanceMath.*bindings with NaN guards.web: Implements the DOM and HTML5 2D Canvas handle table, bidirectional UTF-8 string boundary protocol, animation loops (requestAnimationFrame), and keyboard event handlers.
Compile directly to WebAssembly in the Browser — No Server, No JVM
Most online code runners send your source code to a remote container, compile it using a cloud JDK, and stream the console stdout back over WebSockets. WasmCoffee does the opposite: it is a true client-side compiler.
Your source code is never transmitted across the network, ensuring total privacy and zero latency. The entire compiler weighs under 10 MB and runs in your browser without sending your code to a server. Whether you are experimenting with algorithms, testing class hierarchies, or building 2D animations, you get instant compilation feedback with zero configuration.
Language Features & Java-Inspired Syntax
WasmCoffee accepts a practical object-oriented language using Java-inspired syntax:
- Data Types —
int,long,short,byte,float,double,boolean,char,String, and single/multi-dimensional arrays (e.g.int[],Object[]). - Object-Oriented Programming —
class,abstract class,interface, constructors,this,super, method overloading, overriding, and runtime polymorphism. - Modern Java —
recordtypes,sealedhierarchies withpermits,instanceofpattern variables (o instanceof String s),switchexpressions whose arms name types,@Override, lambdas, and method references. - Generics & Collections — generic classes and methods,
List/ArrayList,Map/HashMap,Set/HashSet,List.of, andArrays.sort/Arrays.toString. - Control Flow —
if/else,forloops,whileloops,do/while,switch/case/default,break,continue, andreturn. - Standard Library & Math —
System.out.println()for every primitive,String, and object (with decimal formatting forfloat/double), string concatenation,StringBuilder, theInteger/Long/Doublewrappers,System.nanoTime(), and standardMathmethods:sin,cos,tan,asin,acos,atan,atan2,exp,log,log10,pow,cbrt,hypot,sinh,cosh,tanh, andMath.PI. - Web APIs — Interacting with HTML5 Canvas 2D via the
Webclass for high-performance interactive graphics.
Learn Java with JavaK
Looking for a comprehensive, beginner-to-advanced Java learning resource? Explore JavaK (javak.co.za), an open Java course covering fundamental programming concepts, syntax, object-oriented design, algorithms, and data structures.
Built-In Examples
Select any example from the dropdown in the toolbar to explore different capabilities:
HelloConsole.java— Fibonacci number generation, arithmetic operations, and console output.SortingAlgorithms.java— In-place Bubble sort implementation on integer arrays with before/after verification.ObjectPolymorphism.java— Abstract base classes, concrete sub-classes, virtual method overrides, and polymorphic iteration.CanvasBouncer.java— Real-time interactive multi-particle physics simulation rendered on HTML5 2D Canvas at 60 FPS usingrequestFrame.ModernRecords.java—recordtypes, asealedinterface, andswitch/instanceofpatterns.CollectionLab.java— generic methods and theList/Map/Setcollections, plusArrays.sortandArrays.toString.NanoClock.java— timing with the monotonicSystem.nanoTime()clock.CircularGauge.java— an animated needle gauge, a Java port of theTCircularGaugecontrol from the Delphi/Lazarus SkeuoCom library, drawn entirely with Canvas 2D ellipses, gradients, ticks and text.GaugePanel.java— SkeuoCom's circular gauge, linear bar gauge and VU meter drawn side by side on one panel, each control rendering into its own translated Canvas state.- Language demos (ported from the WasmPascal example corpus) —
StringLab,Ordinals,CaseRanges,AsciiShapes,TernaryDemo,TypedConsts,MultiDim,EnumsAsConstants,SetAsBitmask,FieldAccess,UnicodeText, andAddAndCheck. - Canvas games —
Pong2D,Breakout2D, andXonix2Dread the keyboard throughbindKeysand animate withrequestFrame;Transforms2Dshows the full transform stack and gradients, andParticleFountainis driven by pointer events throughbindPointer.
Frequently Asked Questions
Does my code leave my browser?
No. WasmCoffee is an entirely client-side environment. Source code is written directly into the WebAssembly compiler memory inside your browser and compiled in a Web Worker. Nothing is ever sent to a remote server.
What browsers support Wasm-GC?
Wasm-GC (WebAssembly Garbage Collection) is natively supported by modern browsers: Google Chrome 119+, Mozilla Firefox 120+, Microsoft Edge 119+, and Apple Safari 18.2+.
Do I need a JVM or JDK installed?
No. Neither an Oracle JDK nor a JVM is required on your machine. The compiler is an independent clean-room toolchain built from scratch and compiled from Odin to WebAssembly, running directly on your browser's native WebAssembly virtual machine without any proprietary runtime components.
How fast is compilation?
Compilation is fast. The bundled examples finish in under 20 milliseconds, and even a ~250 KiB source file compiles in well under 100 milliseconds — a pretty fast compile-and-run loop.
Can I build games and 2D animations?
Yes! The built-in Web bridge provides direct access to HTML5 2D Canvas contexts (shapes, paths,
text, fills, strokes) and 60 FPS frame updates via Web.requestFrame().
About the Developer
I'm Ewald Horn, a software developer: I build all kinds of things, not just compilers. WasmCoffee is one example from a personal collection of small browser projects used to explore systems programming, WebAssembly, and simulation from first principles. I might be available for freelance development work.
You Might Also Like: WasmPascal
If you enjoy in-browser compilation and classic programming languages, check out WasmPascal (wasmpascal.com). WasmPascal compiles modern and Turbo Pascal source code directly to WebAssembly entirely inside your browser. With zero installation and no server backend, it features an interactive editor, retro text-mode CRT console simulation, HTML5 2D Canvas rendering, and playable arcade games running at full speed on modern web standards.
Acknowledgements & Credits
WasmCoffee is built with gratitude on open-source foundations:
- CodeMirror 6 (by Marijn Haverbeke and contributors, MIT License) — powers the in-browser code editor with virtualized DOM rendering, syntax highlighting, bracket matching, active-line highlight, and auto-indent.
- Odin Programming Language — powers the core compiler engine and C-ABI browser driver.
- JavaK — comprehensive open Java learning curriculum by Ewald Horn.
Trademark & Non-Affiliation Notice
Java is a trademark or registered trademark of Oracle Corporation and/or its affiliates in the United States and other countries.
WasmCoffee is an independent educational and developer project created by Ewald Horn. It is not affiliated with, sponsored by, endorsed by, certified by, or associated with Oracle Corporation.
WasmCoffee provides an in-browser compiler for code written with Java-inspired syntax, emitting standard WebAssembly (Wasm-GC). WasmCoffee does not contain, use, reproduce, or distribute any proprietary Oracle source code, binaries, libraries, Java Virtual Machine (JVM) implementations, or intellectual property of Oracle Corporation or any third party.
License & Terms
WasmCoffee is freeware provided free of charge under the WasmCoffee End-User License Agreement (EULA).
WasmCoffee — End-User License Agreement (Summary)
WasmCoffee is provided free of charge for lawful personal, educational, and commercial use. All rights are
reserved by the author (Ewald Horn). You may not misrepresent the origin of the software or claim authorship of
the compiler, IDE, or runtime bridges.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. For full terms,
conditions, restrictions, and governing law, see the complete LICENSE / EULA document.