
Getty Images
How to use ChatGPT in mainframe modernization
ChatGPT can help IT admins manage mainframe applications by converting, optimizing and improving code. It can also create checklists and provide advice for mainframe management.
It's probably safe to say that ChatGPT wasn't created with mainframe operations in mind. Even so, there are some ways that organizations relying on mainframes might benefit from ChatGPT. This is particularly true when it comes to mainframe modernization.
Mainframe modernization takes many different forms, from hardware upgrades to updating applications. Even moving mainframe applications to the cloud could be considered a form of mainframe modernization. So, with that in mind, here are a few ways ChatGPT can help.
How can ChatGPT help with mainframe operations?
When it comes to using ChatGPT for mainframe modernization, creativity is the key to success. ChatGPT is useful for tasks such as code conversion, code optimization and code improvement, but there could be other uses.
Code conversion
ChatGPT can convert code running on a mainframe to another language. This is especially helpful for users planning to migrate an application to a PC-based or cloud platform, or if an application was written in a language that's no longer supported.
The ChatGPT interface makes it seem as though you can only use a single line of text as input. Pressing Enter to go to the next line causes ChatGPT to process what you've already typed. However, there's a way to make ChatGPT convert blocks of code.
To show how this works, I found a sample Hello World application written in COBOL, which was the language used to code countless legacy mainframe applications. To make ChatGPT convert COBOL code into something more modern, I copied the code from the website and pasted it into Windows Notepad. From there, I typed a line above the code that said, "Convert this code from COBOL to Java:". Figure 1 shows what this looks like.

The next step is to copy everything from the Notepad and paste it into the ChatGPT input field. As shown in Figure 2, using this method enabled me to provide ChatGPT with a multiline input. Upon pressing Enter, ChatGPT sets about converting the code as requested. See the results of this in Figure 3.
One thing to keep in mind when using ChatGPT to generate code is that the results aren't always perfect. Some ChatGPT-generated code can be used as is, while other code will require minor debugging. Occasionally, ChatGPT generates unusable code, but its coding skills improved significantly with the release of the GPT-5 model.


Although this method works, it might not always be practical, especially if you are working with code that is lengthy or consists of multiple files. As an alternative, you can use the Attach option, shown at the bottom of Figure 2. This enables you to attach source files or ZIP files that contain multiple source files.
Once the files are available to ChatGPT, it can assist with code analysis, refactoring, troubleshooting or explaining how unfamiliar code works. ChatGPT's ability to explain what code is doing can be helpful when working with old programming languages, such as COBOL.
Code optimization
Another way to use ChatGPT in mainframe operations is for code optimization. In other words, ChatGPT might be able to rewrite blocks of code to be smaller and more efficient. For example, you could paste a particular function or subroutine into ChatGPT and ask it to optimize the code.
Code optimization can help an application run more efficiently, thereby enabling it to perform better or consume fewer system resources. This is important if you're going to migrate it to the cloud. Code optimization tends to shrink the codebase, which can reduce the chance of security vulnerabilities.
Code improvement
You can also use ChatGPT to make your code more legible. Coding best practices have long stipulated that code should contain comments as a way of helping those who must maintain the code in the future. Even so, looking back at Figure 3, you'll notice that the code ChatGPT has generated doesn't include comments. So why not ask ChatGPT to add comments to your code? See Figure 4 for an example of this.

What else can ChatGPT be used for in a mainframe environment?
Although ChatGPT could improve the code behind mainframe applications, there are other potential uses for ChatGPT in mainframe environments.
ChatGPT can write checklists or step-by-step instructions and give general advice. However, step-by-step instructions tend to be imperfect, as they are heavily affected by software version inconsistencies.
ChatGPT can guide you through various challenges in your mainframe environment. Here are a few examples of some questions you could ask ChatGPT:
- What are the steps involved in migrating an application from an old mainframe to a new mainframe?
- If I move my mainframe application to the cloud, what problems are most likely to occur during migration?
- How can I ensure that my application will perform as well in the cloud as it did when running on my mainframe?
- Is there a way to perform a test migration in a way that won't interfere with production workloads?
- How can I improve the performance of an application that's running on my mainframe?
- What can I do to reduce my mainframe hardware and licensing costs?
Brien Posey is a former 22-time Microsoft MVP and a commercial astronaut candidate. In his more than 30 years in IT, he has served as a lead network engineer for the U.S. Department of Defense and a network administrator for some of the largest insurance companies in America.