Online COBOL Compiler
Compile and run COBOL online with GnuCOBOL 3.2. Write a program in free format, press Run, and GnuCOBOL compiles it and starts it, with compiler errors shown by line if the build fails. Programs can read input with ACCEPT and show prompts with DISPLAY as they run.
How to run COBOL code online
- This page opens with COBOL selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
GnuCOBOL 3.2 on Online IDE
- Your program is compiled with GnuCOBOL 3.2 in free format, so code can start in any column and lines can be any length.
- DISPLAY with WITH NO ADVANCING shows a prompt, and ACCEPT reads a line of input into a data item.
- FUNCTION NUMVAL turns the text you read into a number, and FUNCTION TEST-NUMVAL checks it first.
- A program ends with STOP RUN, and STOP RUN RETURNING sets its exit code; indexed files and SCREEN SECTION are not available.
Example: a COBOL program that reads input
IDENTIFICATION DIVISION.
PROGRAM-ID. DIVISORS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 USER-INPUT PIC X(10).
01 NUM PIC 9(6).
01 DIVISOR PIC 9(6).
01 SHOWN PIC Z(5)9.
PROCEDURE DIVISION.
DISPLAY "Enter a whole number: " WITH NO ADVANCING
ACCEPT USER-INPUT
IF FUNCTION TEST-NUMVAL(USER-INPUT) NOT = 0
OR FUNCTION NUMVAL(USER-INPUT) < 1
DISPLAY "Please enter a whole number above zero."
STOP RUN
END-IF
MOVE FUNCTION NUMVAL(USER-INPUT) TO NUM
MOVE NUM TO SHOWN
DISPLAY "Divisors of " FUNCTION TRIM(SHOWN) ":" WITH NO ADVANCING
PERFORM VARYING DIVISOR FROM 1 BY 1 UNTIL DIVISOR > NUM
IF FUNCTION MOD(NUM, DIVISOR) = 0
MOVE DIVISOR TO SHOWN
DISPLAY " " FUNCTION TRIM(SHOWN) WITH NO ADVANCING
END-IF
END-PERFORM
DISPLAY SPACE
STOP RUN.
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which COBOL compiler does Online IDE use?
GnuCOBOL 3.2, which translates COBOL to C and compiles it with GCC 16.
Can I use fixed-format code with sequence numbers?
Yes. Put >>SOURCE FORMAT IS FIXED on the first line, and the rest of the file is read in fixed format, with code from column 8.
Can a COBOL program read input?
Yes. ACCEPT reads a line from the keyboard into a data item. Type into the output panel while the program waits and press Enter.
Can programs use files?
Sequential and line-sequential files in the program's folder work. Indexed files do not, as GnuCOBOL is built here without a database library.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.