Free Reference & Tool · No Signup Required

RPG Fixed vs Free Format

A side-by-side syntax reference for IBM i RPG IV developers, plus a paste-and-detect tool that identifies whether your source member uses fixed-format, free-format, or a mix of both.

Format Detector

Paste any RPG source code and instantly identify its format — Ctrl+Enter to run

Format Detected
Confidence
Evidence

    Side-by-Side Reference

    Six common patterns shown in both formats — bookmark this page

    Every pair shows functionally equivalent code. Fixed-format uses rigid column positions (spec type in column 6; fields occupy precise character ranges up to column 80). Free-format uses readable keywords and statement-ending semicolons. Both compile with modern ILE RPG compilers on IBM i.

    Variable Declaration 01 / 06
    Fixed-Format — D-Spec
    D CustomerName S 50A D OrderTotal S 9P 2 D IsActive S N
    Free-Format
    dcl-s CustomerName varchar(50); dcl-s OrderTotal packed(9:2); dcl-s IsActive ind;
    File Declaration 02 / 06
    Fixed-Format — F-Spec
    FCUSTOMER IF E K DISK FORDERS UF E K DISK
    Free-Format
    dcl-f CUSTOMER disk(*ext) keyed usage(*input); dcl-f ORDERS disk(*ext) keyed usage(*update);
    Assignment & Calculation 03 / 06
    Fixed-Format — C-Spec
    C EVAL OrderTotal = Qty * Price C ADD Tax OrderTotal
    Free-Format
    OrderTotal = Qty * Price; OrderTotal += Tax;
    Conditional (IF / ENDIF) 04 / 06
    Fixed-Format — C-Spec
    C IF OrderTotal > 1000 C EVAL Discount = 0.10 C ENDIF
    Free-Format
    if OrderTotal > 1000; Discount = 0.10; endif;
    Loop & File Read 05 / 06
    Fixed-Format — C-Spec
    C READ CUSTOMER C DOW NOT %EOF(CUSTOMER) C EXSR ProcessRecord C READ CUSTOMER C ENDDO
    Free-Format
    read CUSTOMER; dow not %eof(CUSTOMER); ProcessRecord(); read CUSTOMER; enddo;
    Subroutine & Procedure 06 / 06
    Fixed-Format — BEGSR
    C ProcessRecord BEGSR C EVAL RecordCount = RecordCount + 1 C ENDSR
    Free-Format — Procedure
    dcl-proc ProcessRecord; RecordCount += 1; end-proc;

    Key Differences

    What actually changes when you move from fixed to free format

    Column Positions
    Fixed Columns 6–80 strictly enforced. Spec type in col 6 (F, D, C, H, O, P). Fields occupy exact character ranges.
    Free No column restrictions. Code starts at column 1 and lines can exceed 80 characters.
    Statement Termination
    Fixed Statements end implicitly at the right margin (column 80). No termination character.
    Free Every statement ends with a semicolon ;—identical to C, Java, and most modern languages.
    Comments
    Fixed Asterisk * in column 7 makes the entire line a comment. No inline comments possible.
    Free Double-slash // starts a comment anywhere on a line, including mid-line.
    Line Continuation
    Fixed Complex spec-dependent rules. Factor 2 can overflow to an extended factor 2 line with + in col 76.
    Free Just keep typing — a statement continues until the next ; regardless of line breaks.
    Historical Availability
    Fixed Present since RPG I (1959). All legacy IBM i source members use this format.
    Free Partial free-form since V5R1 (2001). Fully-free **FREE keyword since IBM i 7.2 (2014).
    Mixing Formats
    Fixed H-, F-, D-specs coexist with /FREE…/END-FREE blocks in the same source member.
    Free **FREE on line 1 means the entire member is fully free. No spec letters allowed.

    We handle both formats — and everything in between

    Language Foundry achieves a 99.7% handle rate across 1,739 RPG files, including GOTO/TAG pairs, cycle programs, and multi-format source members that mix fixed-form specs with /FREE blocks. Whether your shop is still on fixed-format or has migrated to **FREE, the transpiler handles it without manual preprocessing.