XCODX |

COBOL Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About COBOL

By most estimates, hundreds of billions of lines of COBOL are still in production — processing bank transactions, insurance claims, payroll runs, and government benefits every single day. Designed in 1959 with Grace Hopper's ideas at its core, COBOL was built to read like business English and to handle exact decimal arithmetic, which is precisely why finance never left it. The language is not frozen: the ISO COBOL 2023 standard is current, IBM ships new Enterprise COBOL releases, and the open-source GnuCOBOL compiler makes learning it free. With mainframe veterans retiring, modernization teams actively recruit developers who can read COBOL. This page compiles COBOL and runs it in a live terminal where ACCEPT statements wait for your real typed input.

Hello World in COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. INTEREST-DEMO.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 USER-NAME       PIC X(30).
       01 NUM-YEARS       PIC 9(2).
       01 ACCT-BALANCE    PIC 9(7)V99 VALUE 1000.00.
       01 YEAR-COUNT      PIC 9(2) VALUE 0.
       01 SHOW-BALANCE    PIC $Z,ZZZ,ZZ9.99.
       PROCEDURE DIVISION.
           DISPLAY "What is your name? " WITH NO ADVANCING.
           ACCEPT USER-NAME.
           DISPLAY "Hello, " FUNCTION TRIM(USER-NAME) "!".
           DISPLAY "Grow $1000 at 5% for how many years? "
               WITH NO ADVANCING.
           ACCEPT NUM-YEARS.
           PERFORM NUM-YEARS TIMES
               COMPUTE ACCT-BALANCE = ACCT-BALANCE * 1.05
               ADD 1 TO YEAR-COUNT
           END-PERFORM.
           MOVE ACCT-BALANCE TO SHOW-BALANCE.
           DISPLAY "After " YEAR-COUNT " years: " SHOW-BALANCE.
           STOP RUN.

When to use COBOL

COBOL is a career play: banks, insurers, and government agencies in the US, UK, Canada, and Australia run core systems on it and pay well for people who can maintain and modernize them — IBM's mainframe training initiatives exist precisely because demand outstrips supply. Use this page to learn the fundamentals recruiters screen for: DIVISION structure, PIC clauses and decimal arithmetic, PERFORM loops, and formatted output. It's also practical for developers on modernization projects who need to decode a copybook or verify how a COMPUTE rounds before touching production JCL.

Common questions

Does ACCEPT take live keyboard input on this page?

Yes — ACCEPT pauses the program until you type a value in the terminal, and DISPLAY ... WITH NO ADVANCING keeps the prompt on the same line, so the classic prompt-and-respond flow works exactly like a terminal-attached batch program. Multiple ACCEPT statements in sequence each wait for their own input.

Which compiler runs my COBOL, and does it match mainframe COBOL?

Programs compile with GnuCOBOL, the open-source compiler that translates COBOL to C. It follows the standards closely and supports most IBM-style syntax, so the core language you practice — data division layouts, PERFORM, COMPUTE, intrinsic functions — transfers directly to Enterprise COBOL, though mainframe-specific facilities like CICS and DB2 precompilers won't exist here.

Do I need to worry about column positions in my source?

In traditional fixed-format COBOL, yes: area A starts at column 8 and statements begin in area B at column 12, which is why the example indents with seven leading spaces. GnuCOBOL also supports free-format source, but learning fixed format is wise since virtually all legacy mainframe code uses it.

How COBOL runs on XCODX

Sandbox filename
main.cbl
Entry point
single main source file
Editor grammar
text/x-cobol
Reading stdin
ACCEPT
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO-WORLD.
       PROCEDURE DIVISION.
           DISPLAY "Hello from COBOL!".
           DISPLAY "Welcome to XCODX Online Compiler!".
           STOP RUN.