.BAS

BAS File

BASIC Source Code File
Ask a question
QUICK ANSWER

A BAS file is source code written in some dialect of BASIC, a programming language dating to 1964. Open it in any text editor (Notepad++, VS Code) to read or edit it; to run it you need the matching BASIC compiler or interpreter. One exception: old GW-BASIC or QuickBASIC files saved in binary token format look like gibberish in an editor - they need QB64 or the original interpreter to decode.

Developer: N/A (BASIC language family - Dartmouth 1964; many dialects) Category: Developer Files Open standard MIME: text/plain
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 1, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the BAS file format?

.bas is the standard file extension for BASIC source code files. BASIC - Beginners' All-purpose Symbolic Instruction Code - was created at Dartmouth College in 1964 and became the dominant programming language on 1980s home microcomputers. Machines like the Apple II, Commodore 64, and IBM PC all shipped with BASIC interpreters that saved programs as .bas files.

The extension is shared across several distinct dialects:

  • GW-BASIC / QBasic / QB64 Phoenix Edition: Classic Microsoft-lineage dialects. GW-BASIC could save programs in a tokenized binary format (not readable as text); QBasic and modern QB64 use plain-text .bas files, often with legacy line numbers such as 10 PRINT "Hello".
  • Visual Basic 6 / VBA: Standalone code modules export as .bas. These files begin with Attribute VB_Name = "ModuleName", followed by Sub and Function declarations. Form modules use .frm and class modules use .cls instead.
  • FreeBASIC / PureBasic / True BASIC: Modern compilers that each accept .bas as their primary source format, supporting structured and object-oriented code.

A .bas file is plain text with MIME type text/plain and carries no magic bytes - there is no fixed file signature, so the applicable dialect must be inferred from file content or project context. The notable exception is old GW-BASIC files saved without the ,A ASCII flag, which are binary and cannot be opened as text.

Because .bas is plain text, any editor can open it. IDEs such as Visual Studio Code and Microsoft Visual Studio provide syntax highlighting and IntelliSense for modern Visual Basic .bas modules.

Security & safety

RISK: MEDIUM

A .bas is source code - reading it is harmless, but it is a program. Compiling and running an unknown .bas executes whatever it contains, and VBA .bas modules can hold malicious macros (a common malware vector when imported into Office). Read the source before running or importing it, and don't enable/run code from untrusted senders. Plain viewing in a text editor poses no risk.

Format details

in a nutshell
FULL NAMEBASIC Source Code File
DEVELOPERN/A (BASIC language family - Dartmouth 1964; many dialects)since BASIC: 1964 (Dartmouth); .bas widely used since 1980s microcomputers
MIME TYPEtext/plain
TYPEPlain-text program source code
STANDARDOpen · royalty-free
This extension is also used by…
  • VBA / VB6 exported module - A code module exported from Microsoft Office VBA or Visual Basic 6, starting with 'Attribute VB_Name='.
  • Tokenized GW-BASIC / QuickBASIC program - Old MS-DOS BASIC saved in a compressed binary token format (not text) by GW-BASIC/QBASIC.

Programs that open BAS files

Windows7 apps
Microsoft Visual Studio Freemium Open/import VB.NET or VB6-style .bas modules; for general BASIC it's an editor only.
PureBasic Paid Open the .bas in the PureBasic IDE and compile (for PureBasic-dialect source).
FreeBASIC Open-source Compile FreeBASIC .bas from the command line (fbc file.bas) to a native executable.
True BASIC Paid Open and run True BASIC .bas in its IDE (for True BASIC source).
Notepad Open-source Open the .bas to read/edit the source with syntax highlighting (free). Won't run it - just view/edit.
Visual Studio Code Free Open the .bas; add a BASIC/VB extension for highlighting. Editing only - compile with the dialect's toolchain.
QB64 Phoenix Edition Open-source Open and run/compile QBasic/QuickBASIC-style .bas to a native EXE. Best modern home for classic .bas programs.
macOS3 apps
FreeBASIC Open-source Compile FreeBASIC .bas via the fbc command line.
Visual Studio Code Free Open the .bas to read/edit the source.
QB64 Phoenix Edition Open-source Open and run QuickBASIC-style .bas (macOS build available).
Linux3 apps
FreeBASIC Open-source Compile FreeBASIC .bas with fbc.
Visual Studio Code Free Open the .bas to read/edit.
QB64 Phoenix Edition Open-source Open/run QuickBASIC-style .bas (Linux build).

Technical details

deep spec
MIME typetext/plain
File encodingASCII or UTF-8 plain text; a tokenized binary variant exists for GW-BASIC files saved without the `,A` flag
Magic bytes / file signatureNone - no fixed byte sequence; the applicable dialect must be inferred from file content or project context
VBA / VB6 module headerExported modules begin with `Attribute VB_Name = "ModuleName"` followed by `Sub` and `Function` declarations
Classic line-number syntaxEach statement prefixed by a line number (e.g., `10 PRINT "Hello"`, `20 GOTO 10`) in pre-QBasic dialects
Modern block syntaxStructured `Sub`, `Function`, and `End Sub` blocks used in QBasic, VB6, FreeBASIC, and PureBasic
Comment styles`REM` keyword (all dialects) or `'` apostrophe shorthand (QBasic and later dialects)
Case sensitivityKeywords are case-insensitive in most BASIC dialects; identifiers follow the same convention
Execution modelInterpreted in classic BASIC and QBasic; ahead-of-time compiled in FreeBASIC and PureBasic; QB64 Phoenix Edition transpiles to C then compiles natively
Related module extensions`.frm` (VB6 form module), `.cls` (VB6 class module), `.vb` (VB.NET source), `.vbs` (VBScript)
Platform supportOriginally MS-DOS and Windows; FreeBASIC and QB64 Phoenix Edition also target macOS and Linux
Language paradigmProcedural in classic and QBasic dialects; object-oriented extensions available in VB6, FreeBASIC, and PureBasic
Line endingsCRLF (`\r\n`) typical from Windows-based BASIC tools; LF common in Unix-based compilers such as FreeBASIC on Linux
Dialect fragmentationNo single standard - GW-BASIC, QBasic, VB6, VBA, FreeBASIC, PureBasic, True BASIC, and QB64 each have incompatible syntax extensions
ReleasedBASIC: 1964 (Dartmouth); .bas widely used since 1980s microcomputers
Open standardYes · royalty-free
Specificationlearn.microsoft.com

BAS conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with BAS files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about BAS files.

Frequently asked questions

How do I open a BAS file?
It's text, so open it in any editor (Notepad++, VS Code) to read or edit. To run it, use the BASIC tool that matches its dialect - QB64 for QuickBASIC-style code, FreeBASIC or PureBasic for theirs.
How do I run an old QBasic/QuickBASIC .bas today?
Use QB64 Phoenix Edition (free, Windows/macOS/Linux). It's QuickBASIC-compatible, runs most classic .bas programs, and compiles them to a modern native EXE.
I opened my .bas in Notepad and it's gibberish - why?
It's a tokenized (binary) GW-BASIC or QuickBASIC file, not text. Load it in the original interpreter (or QB64) and re-save with the ASCII/text option to get readable code.
What's a .bas file in Excel/Office (VBA)?
It's a VBA code module exported from the VBA editor, starting with 'Attribute VB_Name='. Re-import it via the VBA editor's File > Import File to add the macros to a workbook/document.
Can I convert a .bas to an EXE?
By compiling, not converting - and only with the compiler for its dialect (QB64, FreeBASIC, PureBasic). There's no universal bas-to-exe tool because each BASIC is different.
How do I know which BASIC dialect my .bas is?
Open it in a text editor and look at the syntax: line numbers and GOTO suggest GW-BASIC/QBasic; 'Attribute VB_Name=' means VBA/VB6; '#include' and Dim As suggest FreeBASIC. Pick the matching tool accordingly.

References

1Microsoft - Visual Basic language documentationlearn.microsoft.com
2QB64 Phoenix Edition - modern QuickBASIC-compatible BASICqb64phoenix.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.EXEWindows Executable (Portable Executable)
6.RPMSGRestricted Permission Message
7.MDMarkdown Document
8.DATProgram Data File (generic)
9.NOMEDIAAndroid No-Media Marker File
10.TXTPlain Text File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z