The vast majority of large organizations still have at least one critical system running on code that nobody in the organization actually understands. It could be a COBOL claims engine or a VB6 desktop app that the finance team relies on every single day. It works, so it’s not going to be changed. Year on year, it gets harder and more expensive to change.
AI-powered legacy code modernization is the practice of using AI to read, explain, refactor, translate, and test legacy code faster than a team could do by hand. The aim is to break the cycle of ever-increasing maintenance costs and risks.
The pressure to adopt it is very real. In an October 2025 Pegasystems survey of over 500 IT decision-makers, 78% said the time, money, and effort they were spending on maintaining their legacy applications could be better spent. Just 9% said their transformation work had actually put them in a position to retire or replace all of their legacy applications.
The vast majority of leaders have already made up their minds about the need to modernize. What they’re now asking is how much of the work AI can actually do without altering the business rules that are baked into the code. For a large proportion of the work, the answer is yes, AI can do it. The only thing that needs to be retained is the engineer’s responsibility for intent and verification.
This guide looks at where AI is currently delivering value, where it’s still not up to the mark, and how you can run a faster program without introducing new risk.
Legacy code is code that the business still relies on but can’t easily or safely change. It’s the code that runs the core bits of business (billing, claims, payroll, order processing, etc.) and it’s been in production for years or even decades.
Age in itself doesn’t make code legacy. In Working Effectively with Legacy Code, Michael Feathers defines it as simply code without tests. In reality, legacy code tends to have a number of characteristics in common:
Legacy code isn’t bad code. It’s code that has implemented years of business decisions, and it still works. The aim of modernization is to preserve that behavior and move it onto a stack that the team can then own, secure, and extend.
Legacy code doesn’t usually say it needs modernizing. The signs are often in delivery metrics, audit findings, and hiring plans. Forrester forecast in October 2024 that 75% of technology decision-makers would view their technical debt as moderate or high severity by 2026, in part due to the complexity that new AI solutions introduce.
Check your codebase against these signals:
When a number of them apply at the same time, waiting will usually end up costing you more than just going ahead and doing it.
AI-powered legacy code modernization uses large language models (LLMs), coding agents, and traditional static analysis to understand, document, restructure, and test the legacy code. The aim is to get that code onto a modern stack while preserving its behavior.
Gartner now has this as a separate software market. Their Peer Insights category for AI-augmented code modernization covers tools that bring together AI agents, generative AI, and deterministic analysis. The work they can do includes code and architecture analysis, documentation, dependency mapping, migration planning, and refactoring.
The practical shift is in who does the reading. In a classic legacy code modernization project, senior engineers spend months reading through the code and tracing code paths before anyone writes any new code. With AI, that entire first reading pass is effectively automated, and engineers are then left with the task of reviewing the findings and making decisions.
Insight: Measure success by behavior. If the new code produces the same results as the old code for the same inputs, it doesn’t need to be line-for-line the same as the old code.
The hardest part of modernizing legacy code isn’t writing the new code at all. It’s getting to the point where you actually understand the old code well enough to be able to change it without breaking the business rules that are embedded in it. That work is almost always the preserve of a very small number of senior engineers, and so it’s slow, expensive, and difficult to scale.
AI changes that in three ways:
Engineers remain responsible for intent and approval. AI takes on the bulk of the repetitive work that previously made these programs so slow to start. How much AI actually helps depends heavily on the stack you’re starting from.
AI doesn’t help with every stack equally. It works best with languages that have a huge amount of public code and clear modern equivalents. It struggles with the rare dialects and the proprietary 4GLs. Set your expectations accordingly before you even start thinking about a legacy code migration. See the table below.
| Legacy stack | Common target | AI fit | Watch for |
| COBOL and PL/I on the mainframe | Java or C# | High for comprehension and documentation, and medium for translation | Decimal arithmetic, JCL batch flows, CICS screens, shared copybooks |
| VB6, Delphi, PowerBuilder | .NET or web front ends | Medium to high | UI and data-access logic mixed together, and third-party controls with no modern equivalent |
| .NET Framework 4.x | Current .NET LTS release | High | WCF, Web Forms and Windows-only APIs |
| Java 8 or 11 | Current Java LTS with Spring Boot 3 or later | High, mostly through deterministic recipes | The javax to jakarta namespace change and removed APIs |
| AngularJS | Angular or React | Medium | Two-way binding patterns, custom directives, rewriting the test suite |
| PHP 5 and Python 2 | Current PHP and Python 3 | High | String and bytes handling and removed extensions |
The overwhelming majority of modernization projects are held up by a lack of knowledge. The actual coding of the new software is rarely the bottleneck. AI is most effective as an assistant that fills the gaps, with the human making the final call at each stage. These are the five problems it is best at solving right now.
The first few weeks of any program are spent getting to grips with what already exists. The modern tools will take the codebase and parse it into a code knowledge graph of programs, call paths, data stores, and external interfaces. The LLM then answers the question against that graph via retrieval.
No human team can read a multi-million-line codebase in its entirety, but AI can index the whole thing and answer questions about any section. It can also explain to a developer what COBOL, RPG, or PowerBuilder code does even if they’ve never seen that language before.
Business rules (discounts, eligibility checks, rounding, etc.) typically only exist in the conditional statements themselves. Business rules extraction is the process of taking those rules out of the conditional statements and presenting them as rules that a business analyst can validate. A simple example would be a rule that any order above a certain value from a certain region would be exempt from manual review. The AI can produce these rules extremely quickly and, of course, link each one back to the line of code it was extracted from.
A subject matter expert then goes through and accepts, modifies, or rejects each rule. It’s that review process which makes the extracted rules safe to build on.
Hidden dependencies are by far the biggest cause of failure in a modernization project. AI can traverse call graphs and data flows across modules, identify every call to a deprecated library or API, and suggest a replacement for each one.
Version upgrades (e.g., Java 8 to a current LTS, .NET Framework to modern .NET) are largely mechanical. The recipe-based tools do the bulk of the work in a fairly consistent manner. The AI then deals with the bits that the recipes can’t deal with (custom wrappers around APIs that have been deprecated, etc.).
AI code refactoring is the process of re-organizing the code in the same language. This involves breaking up long procedures, removing dead code, and introducing clear interfaces. AI code translation is the process of moving code into a different language (e.g., COBOL to Java, VB6 to C#).
The main benefit over older converters is the quality of the generated code. A good AI-assisted translation will produce Java that is properly structured as Java (i.e., classes, exceptions, standard libraries, etc.) rather than Java that is just COBOL structure in Java syntax. The drawback is that the AI output isn’t fully repeatable, so every translated unit has to go through the same test suite as the original.
Before you touch any legacy code, you need proof of what it actually does today. Characterization tests (a term Michael Feathers coined in Working Effectively with Legacy Code) record the current behavior as the expected result, including behavior that looks wrong. AI can generate them in quantities that no team could possibly write by hand.
One caveat: a generated test will pass against today’s code by design, so if today’s code has a bug, the test will now protect that bug. Any test that produces a result surprising to the business should be reviewed by the business before you treat it as correct.
Documentation is one of the safest uses of AI right now, because people read and check the output before acting on it. AI can generate module summaries, data flow descriptions, and interface notes for code that has absolutely no documentation. If you’re using AI to document legacy code, you want it to provide you with a plain English summary of each module, its inputs and outputs, and the conditions that cause it to behave differently.
What AI won’t fix: unclear system ownership and a business that can’t agree on the rules the AI has extracted. Those are management issues, and they hold up AI projects as much as they hold up manual projects.
The business case for AI-powered legacy code modernization is all about time. In March 2025, Airbnb’s engineering team laid out how they’d used LLMs to migrate nearly 3,500 React component test files from Enzyme to React Testing Library.

The team had estimated it would take 1.5 years of engineering time to do it by hand. With LLM-driven automation, the team finished in about six weeks, and a short manual pass cleaned up the remaining files.
Beyond speed, the benefits that matter to leadership are these:
Insight: In that very same IDC study of 500 large organizations, only 12% had moved to a continuous, AI-driven optimization model. The rest are still in the reactive modernization cycle, so teams that put that discipline in place now will be well ahead of the game.
Successful programs treat AI as a fast but junior contributor within a disciplined process. The six steps achieve the right balance between speed and control.

How to Choose the Pilot Module
Your first module will set the bar for the whole program. A pilot that’s too easy says nothing; a pilot that’s too risky can kill the program off in its infancy. Plot your candidates against business value and technical risk.

Aim for the high-value, low-risk quadrant. There’s something in that quadrant that is important to the business, has well-defined interfaces, has very few upstream dependencies, and has an owner who can confirm the rules.
There’s no one product that does it. Most solutions are a mix of three or four AI code modernization tools, each good at one thing. Adoption is definitely picking up. In April 2024, Gartner predicted that 75% of enterprise software engineers will be using AI code assistants by 2028 (up from under 10% in early 2023).
Guideline: Use deterministic tools when you want the same answer every time. Use LLMs when you want an explanation, and use agents only in situations where you can have a test suite that can automatically verify the result.
The table below sets out the principal categories of tools, with example products in each.
| Category | What it does | Examples | Best for |
| AI coding assistants | Explain, refactor, and test code inside the IDE | GitHub Copilot, Amazon Q Developer | Module-level work by your own developers |
| Mainframe modernization suites | Analyze, refactor, and move COBOL and PL/I workloads | BMC AMI DevX, Rocket Enterprise Suite, AveriSource Platform | z/OS estates |
| Deterministic refactoring at scale | Apply repeatable, recipe-based changes across many repositories | Moderne (built on OpenRewrite) | Language and framework upgrades |
| Code intelligence and visualization | Map architecture, dependencies and data flows | CAST Imaging, CoreStory | Discovery and planning |
| Unit-test generation | Write regression tests for existing code | Diffblue | Locking behavior before change |
| Autonomous coding agents | Plan and carry out multi-file changes under review | Devin AI, Blitzy | Bounded tasks with clear tests |
Most of the examples are taken from vendors in Gartner’s Peer Insights category (as viewed Nov 2026). They’re there to illustrate the various categories and in no way constitute an endorsement.
AI shifts the engineering time away from reading and typing and towards deciding and checking. In any AI-driven legacy code modernization program, the people retain ownership of intent, judgment, and accountability. Here’s how that splits across the team:
A very simple way to assign responsibility is to put every AI task between two human steps. Someone sets up the task, the AI does the bulk of the work, and then people check the result prior to it moving on.

The bulk of the effort is in the AI in the middle. Human time is spent on the two ends, where a mistake is very expensive. If a change fails review, it goes back to the AI with the reviewer’s comments and never makes it to production until it’s been verified.
Speed is of no use if no one believes the output, and it’s clear developers are highly skeptical. The 2025 Stack Overflow Developer Survey found that 84% of respondents use or plan to use AI tools. That said, most are far more skeptical about the accuracy of those tools than about trusting them.

That’s the gap. Quality and security controls have to be in the program from the very first sprint, before any AI-generated code reaches a release branch.
Quality Gates
| Risk | What it looks like | Control |
| Hallucinated APIs | Code calls methods or libraries that do not exist | Compile and test gates, and dependency allow-lists |
| Silent logic drift | Translated code rounds, sorts, or handles nulls differently | Output comparison on production-like data |
| Tests that confirm old bugs | Generated tests lock in existing defects | Business review of any surprising expected result |
| Source code and IP exposure | Proprietary code sent to an external model provider | Private hosting or zero-retention terms, and contract review |
| License contamination | Generated code closely matches copyleft-licensed code | Code-similarity and license scanning in CI |
| Secrets in old code | Hard-coded passwords and keys indexed by AI tools | Scan and rotate secrets before indexing |
| Runaway usage costs | Token-based pricing spikes during large batch runs | Budgets, rate limits and per-team usage reports |
Set baselines during the pilot, then track these six measures for every module:
Report these alongside the delivery metrics (deployment frequency, change failure rate, etc.) so leadership can see the program’s value in business terms.
AI is weakest when the context is outside the code. That’s where most teams run into trouble, so plan for each challenge below from day one..
| Challenge | Description | How to Address It |
| Limited context on large codebases | Very large monoliths exceed what an AI model can consider at once. Without a dependency map, it may miss effects that cross module boundaries. | Map dependencies first. Then provide the model with one bounded module at a time, along with the interfaces it interacts with. |
| Inconsistent output | Output varies between runs, making audits and reproducibility difficult. | Log prompts, model versions, and results. Use deterministic tools for changes that must produce identical results every time. |
| No view of runtime context | Job schedules, JCL, configuration files, and data quirks often explain behavior that cannot be understood from source code alone. | Include these files in the AI’s working context and verify results by replaying recorded production inputs. |
| Weaker results on rare languages | Quality drops with rare dialects, proprietary 4GLs, and heavily customized frameworks due to limited public training examples. | Pilot on the specific dialect first, allocate additional review time, and consider tools designed for that platform. |
| No authority over business intent | When a business rule appears incorrect, only the business team can determine whether it is a bug or an intentional exception. | Assign every questionable rule to a named business owner and obtain sign-off before making code changes. |
Developers feel these limits every day. In the 2025 Stack Overflow survey, 66% cited “AI solutions that are almost right but not quite” as their biggest pain point and 45.2% said debugging AI-generated code takes longer. Rework can be reduced with small pull requests, clear acceptance tests, and well-curated context files (e.g., coding standards, a domain glossary).
Security, IP, and cost risks (e.g., hallucinated APIs, source code exposure, runaway token spend) are all dealt with in the Quality & Security section above.
At SparxIT, we treat AI-augmented legacy code modernization as an engineering discipline with AI baked in. Every engagement is run to the same five principles:
Not sure where to start? Our AI consulting team can review your codebase and propose a low-risk pilot tailored to your stack.
Legacy code is full of the business decisions of the past few decades. AI lets teams read, explain, and move that code far faster than ever before, as long as we’ve got a disciplined process in place to prevent any behavioral drift.
Start with one module. Test it, observe its behavior, measure the outcome, and use that measurement to work out how far and how fast to scale. That’s the way to do it. AI-powered legacy code modernization takes a piece of software that’s been sitting still for a long time, possibly in a very high-risk state, and turns it into a series of small, verifiable outcomes.
For the wider strategy beyond the code, have a look at our guides on AI-assisted legacy modernization and legacy application modernization with AI.
AI can produce working Java for a large proportion of the COBOL programs. That said, the code absolutely has to be reviewed before it’s released. Decimal arithmetic, file handling, and any logic that’s dependent on JCL or CICS context are all potential areas of failure. Every program that’s been converted will require equivalence testing and the sign-off of a developer before it goes into production.
Yes, it can be safe with the right setup. Go for private or single-tenant deployments where you can, have zero retention terms, and a contractual obligation that your code won’t be used to train their models. Run a secret scan before any code is indexed, and if you have data residency requirements, make sure you know exactly where the data is hosted.
It’s all about code size and language, the amount of test coverage you already have, the state of the documentation, the number of integrations, the scope of compliance, the AI pricing model, and the reviewers you have available. The best figure is from a pilot. Take the time and cost per thousand lines from one representative module and scale that up to the whole codebase, then throw in a bit of contingency for the more difficult modules.
No, AI won’t replace developers on a modernization project. It changes what they do. They’re going to spend less time reading and typing and more time on review and testing and making the design decisions. Any program that reduces engineering capacity too early is going to lose the review capacity it needs in order to trust the output.
AI delivers the best results for the widely used languages that have a massive amount of public code behind them (Java, C#, JavaScript, Python, etc.). AI can explain COBOL quite well, but any translation from it would require a great deal of verification. The rarer the dialect and the more proprietary the 4GL, the harder it is to modernize with AI. The stack table earlier in this guide has the full comparison.
Use multiple layers of checking. Generate tests that capture the current behavior prior to any change, replay the recorded production inputs through both versions, and automatically compare the outputs. Then run both systems in parallel for a period and get the business owner to approve any of the remaining differences.
No. AI can generate documentation and characterization tests from existing code. However, teams must run tests successfully and have subject matter experts review extracted business rules and unexpected results.