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
.basfiles, often with legacy line numbers such as10 PRINT "Hello". - Visual Basic 6 / VBA: Standalone code modules export as
.bas. These files begin withAttribute VB_Name = "ModuleName", followed bySubandFunctiondeclarations. Form modules use .frm and class modules use .cls instead. - FreeBASIC / PureBasic / True BASIC: Modern compilers that each accept
.basas 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: MEDIUMA .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- 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
Technical details
deep spec| MIME type | text/plain |
| File encoding | ASCII or UTF-8 plain text; a tokenized binary variant exists for GW-BASIC files saved without the `,A` flag |
| Magic bytes / file signature | None - no fixed byte sequence; the applicable dialect must be inferred from file content or project context |
| VBA / VB6 module header | Exported modules begin with `Attribute VB_Name = "ModuleName"` followed by `Sub` and `Function` declarations |
| Classic line-number syntax | Each statement prefixed by a line number (e.g., `10 PRINT "Hello"`, `20 GOTO 10`) in pre-QBasic dialects |
| Modern block syntax | Structured `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 sensitivity | Keywords are case-insensitive in most BASIC dialects; identifiers follow the same convention |
| Execution model | Interpreted 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 support | Originally MS-DOS and Windows; FreeBASIC and QB64 Phoenix Edition also target macOS and Linux |
| Language paradigm | Procedural in classic and QBasic dialects; object-oriented extensions available in VB6, FreeBASIC, and PureBasic |
| Line endings | CRLF (`\r\n`) typical from Windows-based BASIC tools; LF common in Unix-based compilers such as FreeBASIC on Linux |
| Dialect fragmentation | No single standard - GW-BASIC, QBasic, VB6, VBA, FreeBASIC, PureBasic, True BASIC, and QB64 each have incompatible syntax extensions |
| Released | BASIC: 1964 (Dartmouth); .bas widely used since 1980s microcomputers |
| Open standard | Yes · royalty-free |
| Specification | learn.microsoft.com |
BAS conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about BAS files.