Software Development

How to Modernize a Legacy Application: Rewrite, Refactor or Replatform?

A risk-based framework for choosing between rehosting, replatforming, refactoring, rewriting and replacing a legacy application, plus a step-by-step plan that avoids the big-bang rewrite trap.

Quick answer

Legacy application modernization means updating an old system so it is cheaper, safer and easier to change. Replatform when the code is sound but the infrastructure is old, refactor when the business logic is valuable but hard to change, replace with SaaS when the function is generic, and rewrite only when nothing else works. Modernize in small, reversible steps.

How to Modernize a Legacy Application: Rewrite, Refactor or Replatform?

Photo: Unsplash

On this page

Almost every business runs at least one application that everyone is afraid to touch. It might be a 15-year-old order system, an Access database that runs payroll, or a custom portal built by a developer who left years ago. It works, mostly. But every change is slow, security patches are getting harder to find, and the people who understand it are retiring.

You are not alone. In July 2025, the US Government Accountability Office reviewed 69 federal legacy systems and flagged 11 as most in need of modernization. Several of them relied on outdated languages, unsupported hardware or software, or had known cybersecurity weaknesses.

The question is not whether to modernize, but how. This guide compares the main paths, gives you a risk-based way to choose, and lays out a plan that avoids the most common failure: the big-bang rewrite.

What counts as a legacy application

“Legacy” does not just mean old. An application is legacy when it is still valuable to the business but expensive or risky to change. Common warning signs:

  • It runs on an operating system, database or framework that is out of vendor support.
  • Only 1 or 2 people know how it works, and documentation is thin.
  • Small changes take weeks and often break something unrelated.
  • It cannot connect to modern tools without manual exports or brittle scripts.
  • Security scans keep flagging issues you cannot easily patch.
  • Hosting or licensing costs keep rising for hardware nobody wants to maintain.

Much of this is accumulated technical debt: shortcuts and outdated choices that make every new change more expensive.

The modernization paths compared

Cloud providers and analysts use slightly different names, but the options come down to a spectrum from “change little” to “start over”. AWS Prescriptive Guidance, for example, describes 7 strategies for moving applications: retire, retain, rehost, relocate, replatform, repurchase and refactor. For modernization decisions, these are the paths that matter most.

Path What changes Typical effort Risk Best when
Retain Nothing for now Very low Low short term, rising long term The app is stable, low risk and due for retirement soon
Rehost (lift and shift) Infrastructure only; code unchanged Low Low You need to exit a data center or old hardware fast
Replatform Swap underlying pieces, such as moving to a managed database or containers Low to medium Low to medium The code is sound but the runtime, OS or database is outdated
Refactor Restructure code without changing behavior, often module by module Medium to high Medium Business logic is valuable but hard to change or scale
Re-architect Change the design, such as splitting out services High Medium to high The architecture itself blocks scale or speed
Rewrite (rebuild) New code from scratch Very high High The technology is dead and the logic is simple or well understood
Replace (repurchase) Move to off-the-shelf or SaaS software Medium Medium The function is generic, such as CRM, HR or accounting
Retire Switch it off Low Low Nobody really uses it, or another system already covers it

A quick note on terms: if you are moving a whole portfolio to the cloud, our cloud migration checklist covers the full 7 Rs in depth. This article focuses on what to do with one stubborn application.

Why big-bang rewrites so often fail

Rewriting from scratch is tempting. The old code is ugly, the new stack is exciting, and a clean slate sounds faster than untangling a mess. In practice, full rewrites carry specific risks:

  • Hidden business rules. Legacy code often contains years of edge cases, such as a special tax rule for one state or a workaround for a big customer. Nobody documented them, so the rewrite misses them.
  • A moving target. The business keeps asking for changes to the old system while the new one is being built, so the rewrite has to chase it.
  • No value until the end. Users see nothing new for months or years, which tests budgets and patience.
  • One risky cutover. Switching everything at once concentrates all the risk into a single weekend.

This doesn’t mean rewrites are never right. Small applications, systems built on truly dead technology, or apps whose logic is simple and well understood can be good candidates. But for most business-critical systems, an incremental approach is safer.

Key takeaway: The safest modernization is usually the smallest change that solves the real problem, done in steps you can reverse. Replatform or refactor first, and save a full rewrite for when the code truly cannot be saved.

The Strangler Fig pattern: modernize piece by piece

The most widely used incremental approach is the Strangler Fig pattern. Microsoft’s Azure Architecture Center describes it as gradually replacing specific pieces of functionality with new applications and services, until the old system can be retired.

How it works:

  1. Put a facade in front. Add a proxy or API gateway that all requests pass through. At first, it sends everything to the legacy system.
  2. Carve out one capability. Pick a well-bounded feature, such as customer notifications or invoice generation, and build it as a new service.
  3. Route traffic to the new piece. The facade sends requests for that feature to the new service. Users don’t notice the switch.
  4. Repeat. Move capability after capability until the legacy system handles nothing and can be shut down.

Supporting techniques make this safer: feature flags let you switch traffic back instantly if something breaks, and running old and new side by side lets you compare outputs before you cut over.

A risk-based framework for choosing your path

Score your application on 2 dimensions: business value (how important and differentiating it is) and technical condition (how healthy the code and platform are).

Poor technical condition Good technical condition
High business value Refactor or re-architect incrementally (Strangler Fig); rewrite only small, well-understood parts Replatform or rehost; invest in tests and small improvements
Low business value Replace with SaaS or retire Retain or rehost; keep costs low

Then adjust for risk with these questions:

  • How much does an outage cost? The higher the cost, the more you should favor small, reversible steps.
  • How well do you understand the business rules? If the honest answer is “not well”, avoid a rewrite until you have captured them in tests.
  • Is there a hard deadline? A data center lease ending or an OS going out of support, such as the end of Windows 10 support in October 2025, often justifies a quick rehost or replatform first, with deeper work later. See our guide on what to do after Windows 10 end of support.
  • Is the function generic? Payroll, CRM and accounting rarely need custom code. Replacing them with SaaS frees your team for work that sets you apart.
  • Do you have the skills? A modern stack your team cannot support just creates a new legacy problem.

Where to start: a step-by-step modernization plan

  1. Inventory and assess. Document what the app does, who uses it, what it connects to, and what it runs on. Note out-of-support components and known security issues.
  2. Define the business goal. “Cut hosting costs by moving off our own servers”, “ship changes weekly instead of quarterly” or “pass a security audit” are goals. “Use microservices” is not.
  3. Build a safety net of tests. Before changing anything, write characterization tests that record what the system does today, including the odd edge cases. Our guide to unit, integration and end-to-end testing explains which layers to cover.
  4. Pick the path per component, not per app. The database might be replatformed, the reporting module replaced with a BI tool, and the pricing engine refactored.
  5. Start with a low-risk, high-learning slice. Choose a piece that is useful but not mission critical, so the team can learn the new platform safely.
  6. Automate delivery. Add version control, automated builds and a CI/CD pipeline early. Modernization means many small releases, and manual deploys will slow you down.
  7. Containerize where it helps. Packaging components in containers can make replatforming easier and environments consistent. See how to containerize an application.
  8. Measure and communicate. Track lead time for changes, incidents and costs, and show stakeholders progress every few weeks.
  9. Retire the old parts. Actually switch off what you’ve replaced, including servers, licenses and data copies. Many projects stall at 90% and end up running 2 systems.

Budgeting and team considerations

Costs vary widely with the size of the system and the path you choose, so be wary of any fixed price before an assessment. In general, rehosting is the cheapest up front, refactoring spreads cost over time, and rewrites concentrate the most cost and risk. For a sense of what drives custom development budgets, see how much custom software development costs.

Plan for:

  • Running 2 systems at once during the transition, including double hosting and support.
  • Knowledge transfer from the people who know the legacy system. Record sessions and turn their explanations into tests and docs.
  • Data migration and cleanup, which is often the slowest and most underestimated part.
  • Training for the team that will own the modern system.

AI coding assistants can help explain unfamiliar code, draft tests and suggest refactors, but they still need careful human review, especially for undocumented business rules. Our look at how AI coding assistants are changing software teams covers where they help most.

Conclusion

Legacy application modernization works best as a series of small, reversible steps tied to a clear business goal. Assess the app’s value and condition, protect current behavior with tests, and pick the lightest path that solves the real problem: rehost or replatform for aging infrastructure, refactor for valuable but tangled code, replace generic functions with SaaS, and rewrite only when the old system truly cannot be saved. Then finish the job by retiring what you’ve replaced.

Sources

Questions readers ask

Frequently asked questions

What is legacy application modernization?

Legacy application modernization is the process of updating an older but still important software system so it is easier to change, cheaper to run and safer to operate. It can mean moving it to new infrastructure, updating its platform, restructuring its code, replacing it with off-the-shelf software or rebuilding it. The right approach depends on the app's business value and technical condition.

Should I rewrite or refactor a legacy application?

Refactor in most cases. Refactoring improves the code step by step while the system keeps running, so risk stays low and value arrives early. Rewrite only when the technology is truly unsupportable and the business rules are simple or well documented. Large rewrites often miss hidden edge cases and deliver nothing until a risky, all-at-once cutover.

What is the difference between rehosting and replatforming?

Rehosting, or lift and shift, moves an application to new infrastructure, such as the cloud, without changing its code. Replatforming also moves it but swaps some underlying parts to gain benefits, such as switching to a managed database service or running in containers. Replatforming takes a little more effort but usually cuts more operational work and cost.

What is the Strangler Fig pattern?

The Strangler Fig pattern is an incremental modernization approach. You place a facade or proxy in front of the legacy system, build new services for one feature at a time, and route that feature's traffic to the new service. Over time the new system takes over everything and the old one is switched off, without a single risky cutover.

How long does it take to modernize a legacy application?

It depends on the size of the system and the path you choose. A simple rehost might take weeks, while incrementally refactoring a large, business-critical system can take a year or more. Breaking the work into small slices means you deliver improvements throughout, rather than waiting for one finish date.

How do I know if my application needs modernization?

Look for warning signs: out-of-support software or hardware, security issues you cannot patch, slow and risky changes, rising hosting or license costs, few people who understand the code, and trouble connecting to modern tools. If several apply and the application is still important to the business, it is time to plan modernization.

Is it cheaper to replace legacy software with SaaS?

Often, for generic functions such as accounting, CRM, HR or payroll. SaaS shifts maintenance, security patching and upgrades to the vendor, though you pay ongoing subscriptions and may need to change processes to fit the product. For software that sets your business apart, custom modernization is usually a better long-term investment.

Reader reviews

Was this guide useful

No reviews yet. Share your experience and help other readers.

Write a review
Your rating
Never shown publicly

Reviews are checked before they appear. We never show your email. Please review only places or services you have used.

Manishdai
Written by

Manishdai

Manishdai writes about the technology that is reshaping every industry — from AI agents and cloud platforms to healthtech, fintech and the IT companies building it all across the United States.