Hello, World
." Hello, World!" crTap Run to execute
main.fth · output appears here
Press Run to execute
Output streams here as your program runs.
Forth is a stack-based, concatenative programming language built around an explicit data stack and a dictionary of words. Instead of named variables and infix expressions, you push values onto the stack and apply words that consume and produce stack items, using postfix (reverse Polish) notation. CompileBytes runs GNU Forth (gforth) 0.7.3, a fast and portable Forth system with an interactive interpreter and compiler.
Programming in Forth means defining new words from existing ones, growing the language toward your problem. A word definition starts with : and ends with ; and runs by manipulating the stack. This minimal, extensible model historically made Forth popular for embedded systems, bootloaders, and resource-constrained environments. Its interactivity and tiny footprint make it an excellent vehicle for learning how stacks and threaded code work.
main.fth is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
." Hello, World!" cr: square ( n -- n*n ) dup * ;
5 square . cr2 3 + . cr
10 4 - . cr: counts ( -- )
5 0 do i . loop cr ;
counts: sign ( n -- )
dup 0 > if ." positive" else ." non-positive" then drop cr ;
5 sign
-3 sign42 constant answer
variable total
10 total !
answer total @ + . cr: sum ( n -- sum )
0 swap 1+ 1 do i + loop ;
5 sum . cr: fact ( n -- n! )
dup 1 > if dup 1- recurse * else drop 1 then ;
5 fact . cr1 2 3 .s cr
swap .s cr
over .s crThe editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Forth is one of 46 single-file compiler scratchpads. Each run submits only main.fth; local sibling-file imports are not enabled.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme.
Download file exports the active Forth source file.