XCODX |

FreeBASIC 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 FreeBASIC

FreeBASIC is a free, open-source BASIC compiler started by Andre Victor around 2004, created first as a code-compatible replacement for Microsoft's QuickBASIC and then extended well past it. Its default dialect keeps familiar BASIC keywords like PRINT, INPUT, and DIM while adding pointers, unsigned types, user-defined types, and object orientation, and a separate QuickBASIC mode runs much older QBasic and QuickBASIC code with few changes. It compiles to native machine code rather than being interpreted, so BASIC programs become standalone executables, which has kept it popular for hobby games, demos, and small utilities. On XCODX your code is compiled with fbc (the version is shown in the badge) and run in a cloud sandbox, so you can try compiled BASIC without a local toolchain. It is not related to Visual Basic; the shared word BASIC names the syntax family, not the runtime.

Hello World in FreeBASIC

Dim As Integer i, total = 0

For i = 1 To 10
    total += i
Next

Print "Hello from FreeBASIC!"
Print "Sum of 1 to 10 ="; total

When to use FreeBASIC

FreeBASIC's strengths are an approachable BASIC syntax that compiles straight to fast native code, close compatibility with old QuickBASIC programs, and low-ceremony control flow that is easy to pick up. Choose it to revive or port QBasic-era code, to write small console tools and hobby games, or as a gentle step from interpreted BASIC into compiled languages. It is a niche pick for team software or web and mobile development, where its community and library set are smaller than mainstream options. In this sandbox it suits console programs - loops, arrays, INPUT-driven logic, and user-defined types - in a single source file.

Common questions

How do I read user input in FreeBASIC with INPUT?

Use INPUT to read one or more values into variables, for example INPUT "Age: ", age, or LINE INPUT to read a whole line of text including spaces into a string. On XCODX the program pauses at INPUT so you can type into the live terminal, or you can paste values into the Stdin Box, and Ctrl+D closes the stream. INPUT splits on commas and parses to the variable's type, so use LINE INPUT when you want the entire line exactly as typed.

Can I use external FreeBASIC libraries like SDL or the built-in graphics here?

No for third-party libraries, and graphics need care. The sandbox compiles a single file with fbc and has no package manager or network, so libraries such as SDL are unavailable, and the built-in SCREEN graphics need a display the cloud runner does not provide. Console features - PRINT, INPUT, string and math functions, arrays, and user-defined types - work, so keep programs text-based here.

Is FreeBASIC the same as QBasic or QuickBASIC?

It is compatible, not identical. FreeBASIC's default dialect modernizes the language, and it also has a QuickBASIC-compatible mode you can request by putting #lang "qb" at the top of the file, which compiles many old QBasic and QuickBASIC programs with few changes. Unlike those, FreeBASIC compiles to a native executable instead of running inside an interpreter, so the old code becomes a standalone program.

Is FreeBASIC related to Visual Basic or VB.NET?

No. They share the BASIC keyword family but are separate projects: FreeBASIC is an open-source native compiler descended from QuickBASIC, while Visual Basic and VB.NET are Microsoft languages that run on the .NET runtime. Code does not port between them directly. On XCODX FreeBASIC is the freebasic option and VB.NET is a different one.

Does FreeBASIC compile to an executable or is it interpreted?

It compiles. fbc turns your source into native machine code and links a standalone executable, which the sandbox then runs, so there is a brief compile step before output appears. This is why FreeBASIC programs run quickly compared with interpreted BASIC dialects. You only see the program's output here, but under the hood a real binary was built and executed.

Do I need to declare variables in FreeBASIC?

By default FreeBASIC lets you use variables without declaring them, but it is good practice to declare them with Dim, for example Dim As Integer count. Adding Option Explicit near the top forces every variable to be declared, which catches typos. Types like Integer, Double, and String make the intent clear and avoid surprises.

How FreeBASIC runs on XCODX

Sandbox filename
main.bas
Entry point
single main source file
Editor grammar
vb
Reading stdin
INPUT
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

' FreeBASIC Program
Print "Hello from FreeBASIC!"
Print "Welcome to XCODX Online Compiler!"

Dim As Integer i, total
total = 0
For i = 1 To 5
    total += i
Next
Print "Sum of 1 to 5 = "; total