wasmpascal — compile Pascal to WebAssembly in your browser

wasmpascal compiles Pascal source to WebAssembly entirely in the browser and runs the freshly compiled wasm on the same page. No install, no server-side toolchain: the compiler itself is a WebAssembly module written in Odin. It supports write/writeln and read/readln console I/O, TextColor and TextBackground, multi-file projects with uses units, heap allocation, and canvas host ABIs for games.

wasmpascal — compile Pascal to WebAssembly in your browser

wasmpascal compiles Pascal source to WebAssembly entirely inside your browser, then runs the freshly compiled wasm on the same page. No file system, no native binary, no server-side toolchain — the compiler itself is a WebAssembly module written in Odin.

This page needs JavaScript to run the compiler. If you have JavaScript enabled, the interactive editor and compiler are available above.

What you can do here

Example programs

wasmpascal

Pascal source
Output / diagnostics
Loading…Theme: Default

wasmpascal: a Pascal compiler that runs entirely in your browser

wasmpascal compiles Pascal source to WebAssembly entirely inside your browser, then runs the freshly compiled wasm on the same page. There is no file system, no native binary, and no server-side toolchain: the compiler itself is a WebAssembly module, written in the Odin programming language and compiled to js_wasm32. Type Pascal in the editor above, press Run, and the compiled program executes right there — console output, canvas graphics, or a full game.

What you can do

How it works

When you press Run, the page spawns a fresh compile worker that loads the compiler wasm module and feeds it your Pascal source through a memory buffer. The compiler runs the full pipeline — preprocess, lex, parse, semantic analysis, code generation, and module emission — and returns compiled wasm bytes. Those bytes are instantiated on the main thread, and the host detects the program's ABI from its exports: console-only programs run in a worker with an inline input line, while canvas and game programs boot straight into the page.

The compiler is a port of the wasmpascal Pascal-to-wasm32 compiler, recompiled to js_wasm32 with its CLI driver replaced by a memory-buffer browser driver. It shares its lineage with zigbasic, which runs a QBASIC interpreter in the browser the same way.

Example programs

Load any of these from the Examples… dropdown in the toolbar:

About the developer

I'm Ewald Horn, a software developer: I build all kinds of things, not just compilers. wasmpascal 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.

Acknowledgements

wasmpascal is built with gratitude on the following open-source projects and tools: