Tutorials
Convert fixed-format RPG to free form: AI or a rule-based tool?
On this page
- What makes an RPG member hard to convert
- Three changes that compile cleanly and still break things
- Rule-based tools to convert fixed-format RPG to free form
- IBM Bob with the Premium Package for i
- Claude, or any general-purpose model
- Which tool for which members
- Prove nothing changed before you promote
- Bottom line
- Frequently Asked Questions
Converting fixed-format RPG to free form is the cheap part of the job. Four kinds of tools will do the syntax for you in 2026, from a free SourceForge utility to IBM Bob’s RPG Modernization workflow. The expensive part is proving the converted program still does what the old one did, because three of the most common rewrites compile cleanly and change behavior anyway.
This is the decision page: what makes a member hard to convert, which tool fits which members, and the test routine to run before anything gets promoted.
What makes an RPG member hard to convert
Most of a fixed-format member converts mechanically. H, F, D and P specs have direct free-form equivalents, and so do CHAIN, READ, IF, DOW and EVAL. The trouble sits in four places.
Opcodes with no free-form syntax. IBM’s free-form opcode table has no entry for ADD, SUB, MULT, DIV, Z-ADD, MOVE, MOVEL, MOVEA, GOTO, TAG, CABxx, CASxx, LOOKUP, SCAN, CAT, SUBST, XFOOT, KLIST, PLIST, SETON or SETOFF, among others. Each one has to become an expression or a built-in function, and that rewrite is where meaning can drift.
I-specs, O-specs and TAG. In a fully free member (**FREE in column 1 of line 1), IBM’s rule is that fixed-form statements “such as a TAG operation, or Input and Output specifications” must live in a copy file. A program that prints through O-specs or reads a program-described file cannot simply be flipped to **FREE.
The RPG cycle. Programs with primary or secondary files depend on cycle timing, control-level indicators and implicit reads. Converting those is a redesign, not a reformat.
OPM source. RPG III and RPG/400 members need CVTRPGSRC to RPG IV first, then the free-form pass.
If your library is mostly ILE RPG with D-specs, externally described files and EVAL-heavy calcs, any tool below will do most of it. If it is full of O-specs and indicators, the tool choice matters a lot more.
Three changes that compile cleanly and still break things
These are the rewrites to search for after any conversion, whoever or whatever did it. The examples below are illustrative and have not been compiled. Assume CUSTNO is packed 7,0, CUSTKEY is character 10, CUSTBAL is packed 9,2, and a display file uses indicator 99 to show “customer not found.”
C CUSTNO CHAIN CUSTMAST 99
C IF *IN99 = *OFF
C ADD ORDAMT CUSTBAL
C MOVE CUSTNO CUSTKEY
C ENDIF
The obvious free-form version:
chain custno custmast;
if %found(custmast);
custbal += ordamt;
evalr custkey = %char(custno);
endif;
It compiles. It is also wrong in three ways.
1. ADD became +=, and overflow became a crash. IBM’s TRUNCNBR keyword decides whether fixed-format arithmetic opcodes truncate high-order digits or raise an error, and if you don’t specify it the command value applies, which has long defaulted to truncation. IBM’s documentation is explicit that TRUNCNBR “does not apply to calculations performed within expressions” and that overflow there causes an error every time. A balance that used to wrap quietly now ends the job. Usually the error is the better behavior, but it needs to be a decision, not a surprise in production. CVTRPGFREE’s own documentation says that if overflow was the intended design, that section should stay fixed-format.
2. MOVE became EVALR, and the data changed shape. MOVE copies right-adjusted and, without the P extender, leaves the leftmost positions of a longer target untouched. EVALR pads them with blanks. %char also drops leading zeros, so 0001234 becomes 1234. A key built this way no longer matches. A faithful version for a positive CUSTNO looks like this:
%subst(custkey : 4 : 7) = %editc(custno : 'X');
That is ugly, and it is supposed to be. The cleanup belongs in a second pass once tests exist.
3. The resulting indicator disappeared. In the fixed version, CHAIN sets indicator 99 on when no record is found, and the display file reads 99. %found keeps the IF correct but never touches *IN99, so the “customer not found” message stops appearing. Until the display file is changed, keep the indicator in sync:
chain custno custmast;
*in99 = not %found(custmast);
Every tool in this article has to make these calls, and every one of them can get them wrong. That’s why the testing section matters more than the tool section.
Rule-based tools to convert fixed-format RPG to free form
Deterministic converters apply the same rules to every member. Run one twice and you get the same output, which means you can diff it, review the rules once and trust them across a library.
CVTRPGFREE is free and open source on SourceForge (version 1.5.14 is the current download). It writes converted source to a new member and leaves the original alone, converts H, F, D and C specs, moves in-line field definitions into D-specs, preserves change dates for CMS tools, and runs across a whole source file with an audit report of lines converted per member. Its documentation is refreshingly blunt: output is “not necessarily 100% compilable,” program-described files are not converted, and MOVE is converted only where it is safe, with an option to switch MOVE conversion off.
ARCAD Converter for IBM i, also sold as ARCAD Transformer RPG, converts C, H, F, D and P specs, can rewrite GOTO, and can run against an entire source library in one operation. IBM’s support page repeats ARCAD’s claim of “near 100% conversion accuracy.” Pricing is not published.
Fortra RPG Toolbox converts RPG III to RPG IV, fixed calcs to free form, and H, F, D and P specs to free form, from SEU or an RDi plugin with 25 conversion preferences. It also includes CLNRPG, which finds unused fields, subroutines, key lists and tags, worth running before conversion so you are not converting dead code. Pricing is quote-only, with a free trial.
RDi’s built-in action has historically converted calculation specs only and left MOVE and GOTO in fixed form, according to long-running WDSCI-L threads. Check your current RDi level before relying on it, and if you are weighing RDi against VS Code with Code for i, don’t let this feature decide it.
IBM Bob with the Premium Package for i
Bob’s approach is the most complete on paper, and it is the only one that targets the hard members directly. The Premium Package for i ships an RPG Modernization workflow that detects the RPG variant, routes OPM source through an OPM-to-ILE path, flags cycle programs, and converts in two phases: first it externalizes I-specs and O-specs, then it converts the remaining H, F, D and C specs. There is an optional compile before conversion and a summary report at the end. IBM’s docs say the workflows mix agentic steps with non-agentic ones that “perform deterministic operations,” which is IBM’s answer to the repeatability problem.
The skills list backs that up: rpg-fixed-to-free, separate skills for program-described database files and printer O-specs, rpg-indicators for replacing numbered indicators with named booleans, and rpg-refactor-legacy for GOTO and subroutines. IBM also ships RPGUnit test plan and test suite workflows, and its own blog pitches them for this exact reason, so a conversion is “verifiable, not just compiled.” If you already use Bob to document RPG IV programs, this is the same tool doing the next job.
Cost: Bob Pro starts at $20 per month, Pro+ at $60 and Ultra at $200, per IBM’s pricing page. The Premium Package for i starts at $40 on top of a paid base plan. IBM is waiving the first month of premium packages for new subscribers until December 31, 2026, which makes a $20 first month the cheapest serious test of this workflow you will get.
What IBM does not publish is a conversion accuracy figure, and we found no independent comparison of Bob’s output against ARCAD’s or CVTRPGFREE’s. Treat the workflow as a strong first draft that still goes through the test routine below.
Claude, or any general-purpose model
Claude Pro is $20 a month ($17 billed annually), and a good general model converts a single fixed-format member surprisingly well, especially when you paste in the D-specs and the display file and tell it the rules above. It is also the best of these options at explaining why a block of indicator logic does what it does.
It is the wrong tool for bulk conversion. There is no IBM i connection, no IBM i skills, no compile loop, and no guarantee that member 40 gets the same treatment as member 4. You also have to send source to a third party, which some IBM i shops’ security policies rule out. Use it for one member you understand well enough to review every line, and for working out what a strange block means before you convert it.
Which tool for which members
| Your members look like | Use | Why |
|---|---|---|
| ILE RPG, externally described files, few MOVEs | CVTRPGFREE | Free, repeatable, audit ratio per member |
| Hundreds of members, budget available | ARCAD or RPG Toolbox | Whole-library runs, tunable rules, vendor support |
| O-specs, program-described files, cycle, OPM | Bob RPG Modernization workflow | Only option that targets I/O specs and the cycle directly |
| One awkward member you need to understand | Claude or Bob in Ask mode | Explanation first, conversion second |
A sensible library plan uses two of these, not one: a deterministic converter for the easy 80 percent and Bob, or a person, for the members the converter skips or comments out.
Prove nothing changed before you promote
This is where conversion projects actually spend their time. A routine that works whatever tool you picked:
- Never convert in place. Convert into a new member or a branch, and keep the original object as the baseline.
- Compile with the original options. Same TRUNCNBR, same activation group, same CCSID. Read the listing for new warnings, not just errors.
- Grep for the three traps. Every
+=or-=on a field that used to be an ADD or SUB result, every EVAL or EVALR that replaced a MOVE, and every numbered indicator that was a resulting indicator in the old source. - Run both programs against the same copy of data and compare what they produce. For database output,
SELECT * FROM OLDLIB.ORDERS EXCEPT SELECT * FROM NEWLIB.ORDERSin both directions finds row differences. For reports, compare the spooled files. - Add RPGUnit tests where procedures exist, written against the old program’s behavior, before you start refactoring the converted code.
If that sounds like more work than the conversion itself, it is. Plan for it. Conversion that skips testing is how shops end up afraid to touch their own code all over again. If your team needs prompts for the explain, document and test steps, the IBM i AI Field Guide covers that workflow.
Bottom line
For most shops that need to convert fixed-format RPG to free form, start with CVTRPGFREE on a copy of one source file and read its audit report. The ratio tells you how much of your library is easy. Put the members it skips (O-specs, program-described files, cycle programs) on a list. That list is what you test IBM Bob’s RPG Modernization workflow against, and the first-month waiver ending December 31 makes now the cheapest time to do it. Buy ARCAD or RPG Toolbox only if the library is big enough that vendor support and tuned rules beat your own review time. Keep Claude for understanding code, not for converting libraries.
Whatever converts the syntax, the job is the same afterward: hunt the three traps, compare output on real data, and promote nothing that has not been run side by side with the original.
Frequently Asked Questions
Can RDi convert fixed-format RPG to free form?
Partly. RDi’s built-in action has historically converted calculation specs only and left operations with no free-form equivalent, such as MOVE and GOTO, in fixed form. For H, F, D and P specs and for MOVE handling you need a converter such as CVTRPGFREE, ARCAD Converter or Fortra RPG Toolbox, or an AI tool.
Is there a free tool to convert RPG to free form?
Yes. CVTRPGFREE on SourceForge is open source, converts H, F, D and C specs into a new member without touching the original, and writes an audit report with a conversion ratio per member. Its own docs warn the output is not always compilable and that it skips program-described files.
Why does my converted RPG program fail with a numeric overflow?
Fixed-format ADD, SUB, MULT and DIV follow the TRUNCNBR setting, which by default lets high-order digits be truncated silently. Free-form expressions ignore TRUNCNBR and always raise an error on overflow. A program that relied on truncation now fails at run time.
Should I use AI or a rule-based converter for RPG free-form conversion?
Use a rule-based converter for bulk work on ILE members, because the output is repeatable and diffable. Use IBM Bob’s RPG Modernization workflow for members with I-specs, O-specs, the RPG cycle or OPM source. Use a general model like Claude for single members you can review line by line, not for bulk.
Share
Grant M.
Developer with IBM i and full-stack experience. Covers AI tools and automation for software developers at PromptedDev, with a focus on real workflows, honest comparisons, and legacy system modernization.
Related reading