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 WebAssembly module and feeds it your Pascal source through a shared memory buffer. The compiler runs the full Pascal to WebAssembly pipeline — preprocess, lex, parse, semantic analysis, code generation, and WebAssembly 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 itself is the wasmpascal Pascal-to-wasm32 compiler, written in the Odin programming language and 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. The whole toolchain is client-side — there is no build server.

Compile Pascal to WebAssembly in the browser — no server, no install

Most online Pascal compilers send your source to a server, compile it with Free Pascal there, and stream the output back. wasmpascal does the opposite: it compiles Pascal to WebAssembly entirely in your browser. Your source never leaves the tab — it is copied into the compiler's linear memory at wasmpascal_source_ptr(), compiled by wasmpascal_compile() running as WebAssembly, and the resulting .wasm bytes are instantiated right on the same page.

The compiler is a single WebAssembly module (about 500 KB) that implements the complete pipeline. It parses Turbo Pascal 7 syntax, resolves uses units from an in-memory store, type-checks with range and set checks, and emits MVP-only WebAssembly — no WASI, no Emscripten shims, no hidden JavaScript runtime. That compiled WebAssembly runs in any modern browser, and you can download it as a standalone .wasm file or bundle it into a standalone web app (.zip folder for any static host, or a single self-contained .html that even opens from file://).

Because the compiler is WebAssembly, privacy and speed are built in: offline after the first load, deterministic builds, and no account or server queue. It is an in-browser Pascal to Wasm compiler you can use to learn, prototype, or ship — the same way you would run fpc locally, but with zero install.

What Pascal you can write

wasmpascal targets a practical Turbo Pascal 7 dialect plus FreePascal and Delphi extensions — enough to write real console programs, data structures, and games that compile to WebAssembly.

Directives like {$mode fpc}, {$M 32M} (heap size), {$Screen 80 25}, and {$R+}/{$R-} range checks are supported; unknown {$...} directives are ignored. The Learn Pascal tutorial (Help → Lessons) walks through every feature above with runnable examples.

An online Pascal IDE — editor, projects, and hosting

wasmpascal is a full online Pascal IDE and Pascal playground: the editor, compiler, and runtime all live on this page. The editor is CodeMirror 6 with Pascal syntax highlighting, bracket matching, and four themes — Default dark plus authentic Turbo Pascal 7 (DOS blue), Borland Pascal, and FreePascal — hot-swapped without losing undo history.

Work in multi-file projects: a named set of .pas files with one root program and any number of uses units, a file dropdown to switch files, and Files… actions to add/rename/remove or promote a new root. Projects autosave to localStorage, and you can upload any number of .pas files from disk or export the whole project as a .zip. The ? quick reference and the Learn Pascal lessons are built in.

When your program compiles, Download… gives you the compiled .wasm, the project .zip, or a ready-to-host standalone web app: a .zip folder (index.html + runtime js + bridges + your .wasm) that runs on any static host, or a single self-contained .html with everything inlined that opens straight from disk. That is how you go from Pascal source to a WebAssembly app you can share.

Example programs

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

FAQ — Pascal to WebAssembly, online compiler, and hosting

Does my Pascal code leave my browser? No. wasmpascal is a true in-browser Pascal compiler — source is copied into the compiler's WebAssembly memory and compiled there. Nothing is uploaded, there is no account, and the page works offline after the first load.

What Pascal dialect does it support? A practical Turbo Pascal 7 dialect plus FreePascal/Delphi extensions: typed consts, set of, conformant arrays, Delphi-style ternary if cond then a else b, and object/class OOP with virtual dispatch. Unknown {$...} directives are silently ignored for compatibility.

Can I learn Pascal here? Yes. The Learn Pascal tutorial (Help → Lessons) teaches the language lesson by lesson with runnable examples you load into the editor. The ? quick reference is the lookup companion.

Can I build games that compile to WebAssembly? Yes. Use the canvas host ABIs: basic_canvas for raw pixel buffers, pascaldom for DOM/canvas (add uses WEB and the whole DOM bridge is in scope — see web_dom.pas), and batchiness for batched-canvas games with Web Audio SFX. Every game example on this page was written in Pascal and compiled to WebAssembly the same way your code is.

Where can I find more example programs? Beyond the built-in Examples… dropdown, the wasmpascal_examples repository on GitHub collects extra Pascal programs you can copy into the editor and run.

How do I host a program I compiled to WebAssembly? Click Download… → Standalone app. The .zip is a folder (index.html + runtime js + your .wasm) you upload to any static host. The single .html is self-contained — CSS, runtime, and your compiled WebAssembly are inlined as base64, so it opens from disk with no server.

How big is the Pascal to WebAssembly compiler? About 500 KB of WebAssembly. The same Odin source also builds the native wasmpascal CLI. In the browser it runs in a fresh Worker per Run (wasmpascal_compile resets global state) and emits MVP-only WebAssembly validated by wasm-validate.

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: