Hello, World!
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
DISPLAY 'Hello, World!'.
STOP RUN.Tap Run to execute
main.cob · output appears here
Press Run to execute
Output streams here as your program runs.
COBOL (Common Business-Oriented Language) is one of the oldest programming languages, designed in 1959 by a committee that included pioneer Grace Hopper. It was built for business, finance, and administrative systems, with an English-like, verbose syntax intended to be readable by non-programmers. COBOL programs are organized into divisions and excel at processing large volumes of records, fixed-format data, and precise decimal arithmetic.
On CompileBytes, COBOL is compiled with GnuCOBOL, reported as version 3.1.2, an open-source compiler that translates COBOL into C and then to native code. Despite its age, COBOL still runs an enormous share of mainframe banking, insurance, and government workloads worldwide. Its structured divisions, the PERFORM statement, and powerful PICTURE clauses for formatting data make it well suited to reliable, long-lived transaction processing.
main.cob 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.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
DISPLAY 'Hello, World!'.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. ADD-NUMS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(3) VALUE 10.
01 B PIC 9(3) VALUE 20.
01 C PIC 9(4).
PROCEDURE DIVISION.
ADD A B GIVING C.
DISPLAY 'Sum: ' C.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. COUNTER.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9(2).
PROCEDURE DIVISION.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
DISPLAY 'Count: ' I
END-PERFORM.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. GREET.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NAME-IN PIC X(20).
PROCEDURE DIVISION.
DISPLAY 'Enter name: '.
ACCEPT NAME-IN.
DISPLAY 'Hello, ' NAME-IN.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. CHECK.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N PIC 9(3) VALUE 42.
PROCEDURE DIVISION.
IF N > 40
DISPLAY 'Big'
ELSE
DISPLAY 'Small'
END-IF.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. PARAS.
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY 'Start'.
PERFORM GREET-PARA.
DISPLAY 'End'.
STOP RUN.
GREET-PARA.
DISPLAY 'Hello from paragraph'. IDENTIFICATION DIVISION.
PROGRAM-ID. AREA.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W PIC 9(3) VALUE 4.
01 H PIC 9(3) VALUE 5.
01 RESULT-VAL PIC 9(5).
PROCEDURE DIVISION.
COMPUTE RESULT-VAL = W * H.
DISPLAY 'Area: ' RESULT-VAL.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. PICKER.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N PIC 9 VALUE 2.
PROCEDURE DIVISION.
EVALUATE N
WHEN 1 DISPLAY 'one'
WHEN 2 DISPLAY 'two'
WHEN OTHER DISPLAY 'many'
END-EVALUATE.
STOP RUN. IDENTIFICATION DIVISION.
PROGRAM-ID. TABLES.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUMS.
05 N PIC 9(2) OCCURS 5 TIMES.
01 I PIC 9(2).
01 TOTAL PIC 9(4) VALUE 0.
PROCEDURE DIVISION.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
MOVE I TO N(I)
ADD N(I) TO TOTAL
END-PERFORM.
DISPLAY 'Total: ' TOTAL.
STOP RUN.The 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
COBOL is one of 46 single-file compiler scratchpads. Each run submits only main.cob; 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 COBOL source file.