You can't get the original Angular source code back from a JavaScript build. What you can get is a partially recovered approximation: unminified module structure, readable template code if the build shipped esbuild metadata or source maps, and component names if those survived the production optimization. The practical route depends on what artifacts you still have—your own project's build output, a deployed app's public files, or a legacy build whose source was lost—and it starts with checking whether a source map exists, because that single file changes the entire approach.

This article covers what each recovery method actually returns, in what order to try them, and where the limits sit. It assumes Angular 2 through the current v19/v20-era CLI toolchain, since the build pipeline (webpack earlier, esbuild-based @angular/build now) determines which artifacts you'll find. Nothing here requires special access beyond what a normal build or a public deployment exposes.

What "the Angular code" means inside a production bundle

Angular's compiler does more than concatenate files. At build time, TypeScript is transpiled, decorators are rewritten, templates are compiled into instructions, and then a bundler (webpack historically, esbuild in the newer application builder) merges everything into a handful of chunk files. A production build additionally runs terser or esbuild minification, which renames local variables to single letters and strips whitespace.

So a deployed main-ABC123.js is not Angular code in any source sense. It's JavaScript that executes the compiled result of Angular code. The original .ts files, the HTML templates, and the SCSS never exist in that file—only their compiled consequences do. That distinction matters because "getting the Angular code" can mean three quite different things:

Recovering the component and module structure so you can understand how the app is organized. Recovering template logic (the *ngIf, bindings, and event handlers) in a form you can read. Recovering near-original TypeScript, which is only realistic if source maps were published.

Each has a different method and a different ceiling. Keep that in mind before starting, because people often run a beautifier, see 40,000 lines of renamed variables, and conclude the task is impossible when the real problem was choosing the wrong target.

Prerequisites before you touch any tooling

Before any recovery step, confirm four things, because they determine which path is even available.

1: Do you own the code or have permission to inspect it? Recovering your own team's lost build is routine maintenance. Decompiling a third party's minified bundle to reuse their logic may violate their license or your local law. The techniques are the same; the permission is not. 2: Do you have the build output directory? A local dist/ folder, a CI artifact, or the files served by the deployed site. If the site is public, browser DevTools shows you every JS file it loads. 3: Does a .map file exist? Check the last line of each JS file for //# sourceMappingURL=. If it points to a .map that actually loads, stop reading the harder methods and go straight to source-map extraction. This is by far the best-case scenario. 4: What Angular and builder version produced it? Angular 17+ defaults to the esbuild-based builder, which emits differently from the older webpack builder. In the new builder, ng build output typically includes main-.js, polyfills-.js, styles-*.css, and optionally *.map files. Knowing which you have tells you what to expect inside.

A quick check of the first and last lines of a chunk file tells you a lot: the sourceMappingURL comment, the presence of readable class names versus mangled ones, and whether the file begins with webpack's runtime bootstrap or esbuild's module wrappers.

Step 1: Check for source maps and extract the original files

Source maps are the only mechanism that can return something close to the actual authored code.

How to check and extract:

1: Open each JS file in the build output and look for the trailing //# sourceMappingURL= comment. 2: If it references a .map file, download or locate that file. Verify it's real JSON containing "sources", "sourcesContent", and "mappings". 3: If sourcesContent is populated, the original source text is embedded directly. You can decode the map with a small script or any source-map library and write each entry to disk under its sources path. 4: If sourcesContent is absent, the map only contains mappings back to file paths that no longer exist on your machine. In that case the map helps you align minified positions to file names but won't hand you the code. 5: Alternatively, load the app in a browser with DevTools open. If the map is served and DevTools resolves it, the Sources panel shows a webpack:// or ng:// tree with the original files, which you can save individually.

What you get: Near-original TypeScript for application code, plus template files if the builder emitted them into the map (the esbuild-based builder does include component templates and styles in source maps for application code). Success looks like a folder tree matching your src/app layout with readable .ts files.

Where it fails: Production builds often disable source maps for size and secrecy, and many teams strip .map files from deployment even when the build generated them. If the map is missing or sourcesContent is empty, this path is closed and you move on.

Step 2: Identify the Angular version and builder from the bundle

When maps aren't available, version identification guides everything after it, because it tells you which runtime internals to expect and which metadata survived.

Look for these signals in the chunk files:

Angular version hints: Search for strings like Angular is running in development mode, NG0, or version-adjacent tokens. The presence of ɵ prefixed identifiers (for example ɵɵdefineComponent, ɵɵelementStart) confirms Angular Ivy-era output, which covers Angular 9 through the present. Older View Engine output looks structurally different and is rare in anything still deployed. Builder hints: A leading webpack runtime (functions with webpack_require) indicates the older @angular-devkit/build-angular webpack path. Bare ES module wrappers with __esm or direct export statements and no webpack runtime point to the esbuild-based builder introduced for Angular 17+. Chunk naming: main-.js, polyfills-.js, and chunk-.js are typical of the modern builder; main..js and numbered chunk files are typical of webpack.

This matters because Ivy compiled output preserves a fair amount of structure: component definitions include selector strings, and ɵɵdefineComponent calls carry template function references. Beautified Ivy output is far more legible than beautified View Engine output. Knowing you're on Ivy sets realistic expectations.

Step 3: Beautify and map the module graph

With no source map, the next best thing is turning the minified stream into something navigable.

Ordered actions:

1: Run each chunk through a JavaScript beautifier (Prettier with --parser babel, or any standard formatter). This restores indentation and line breaks but does not rename anything. 2: Search the beautified output for Angular definition calls: ɵɵdefineComponent, ɵɵdefineNgModule, ɵɵdefineInjectable, and ɵɵdefineDirective. Each defineComponent call is a component boundary, and nearby string literals often include the original selector. 3: Collect the selector strings—they usually survive minification because they're runtime data. A list of selectors like app-root, app-user-list, app-checkout-form reconstructs your component inventory even when class names are gone. 4: Note the template function attached to each component definition. In Ivy, it's a function reference passed as the template property; beautified, it reads as a sequence of ɵɵelementStart, ɵɵtext, ɵɵproperty, and ɵɵlistener calls. Those calls are the compiled template, and reading them reconstructs the HTML and bindings.

Success check: You can list every component selector in the app and, for each, read off the element hierarchy from the ɵɵelementStart/ɵɵelementEnd pairs. If defineComponent calls are present and selectors are readable, this step worked even though class names look like class t {}.

Limit to expect: Variable and class names are mangled, and property names on objects may be mangled too when the minifier was aggressive. You'll recover structure and template logic, not identifiers.

Step 4: Recover component state and template details

The defineComponent output contains more than a selector. Three things are usually extractable with careful reading.

Component metadata. The definition object includes the inputs and outputs maps. Even minified, these often retain the public names as string keys, so you can recover something like inputs: { userId: "userId", items: "items" } and know the component's API surface.

Class members from the constructor and prototype. OnInit-style lifecycle methods are attached to the prototype and referenced by name in the component definition (Ivy stores lifecycle hooks in a features array via ɵɵNgOnChangesFeature and similar). The method bodies are minified but their call structure—which services they invoke, which template fields they touch—is recoverable.

Template bindings and listeners. Inside the template function, ɵɵproperty("label", ctx.someField) recovers property bindings, ɵɵlistener("click", ...) recovers event handlers, and ɵɵtextInterpolate recovers interpolation. Reading a full template function is slow but mechanical, and it yields an accurate picture of what the template did, even if variable names are one letter.

A worked example of the reading method: beautified output like ɵɵelementStart(0, "button"); ɵɵlistener("click", function() { return ctx.onSave(); }); ɵɵtext(1, "Save") reconstructs to Save. You're essentially running the Angular compiler in reverse by hand. For a small app this is an afternoon; for a large one it's not worth it unless you need specific components.

Step 5: Use browser tooling as a live view

DevTools gives you a running view of the recovered structure without writing extraction scripts.

1: Open the deployed app and open the Elements panel. 2: Inspect a rendered component's DOM element; Angular Ivy adds an ng-version attribute to the app root, which confirms the version directly. 3: Watch the Network panel to see which chunks load for which routes. Lazy-loaded chunks are named per feature area (for example chunk-*.js loaded only on /checkout), which lets you map routes to chunks and reduces how much code you need to inspect. 4: In the Sources panel, if maps aren't present, you still get formatted minified code and can set breakpoints. Stepping through a click handler in the debugger is often faster than reading beautified output when you need one specific behavior.

Success check: You can correlate a route to a specific chunk and a specific component definition in the beautified file. This narrows the reading to a manageable section.

Failure mode: Heavily code-split apps produce dozens of chunks with no obvious mapping outside the router configuration. In that case, find the router config first—route paths are string literals that usually survive minification—and follow each route's lazy-load reference to its chunk.

Step 6: Recover styles and assets separately

Templates and logic aren't the only artifacts. Component styles are compiled into the JS (Ivy embeds them in the component definition as an array of style strings) or emitted into styles-*.css. Those strings usually retain their class names and values, so extracting them from the styles property of each defineComponent call restores per-component CSS almost verbatim. Global styles in styles.css come back with class names intact because CSS class names aren't minified by default. Assets like images and fonts are referenced by hashed filenames in the JS and are recoverable by URL. This step is straightforward and worth doing before deep template reading, because the CSS often hints at the template structure (class names point to elements).

Step 7: When the original is genuinely gone, rebuild from structure

If no source maps exist and minified output is unreadable enough that manual reconstruction is impractical, the honest recommendation is to treat the bundle as a specification rather than a source. You have the selectors, the module graph, the routes, the template structure, and the CSS. From those you can rebuild TypeScript that behaves the same, but the identifiers, comments, and exact architecture won't match the original. This is not "getting the code" in any literal sense—it's reimplementation guided by strong evidence.

This is the stop condition for legal and practical purposes too: if the code isn't yours and the license doesn't permit extraction, reconstruction for reuse is a legal question, not a technical one, and needs qualified local advice before you proceed. For your own projects, rebuilding from recovered structure is sometimes faster than hunting for a lost artifact.

Compare the methods before committing

Method Best for What you recover Main limit
Source-map extraction Builds with maps and sourcesContent Near-original TS, templates, styles Maps often absent or stripped
Beautify + Ivy definitions Any Ivy build Component inventory, selectors, templates, bindings Names mangled
DevTools live inspection Route and behavior mapping Route-to-chunk map, runtime behavior No source text
Style and asset extraction All builds Per-component and global CSS, assets No logic
Structured rebuild Lost originals, owned code Behavior-equivalent new code Not the original code

The table isn't a ranking—it's a decision aid. Start at the top; drop down when a row's limit applies to you.

Common ambiguities and edge cases

"Get the Angular code" from someone else's site. Everything above still describes what's technically visible in a public bundle, but visible isn't the same as permitted. Check the license and local rules first; this article can't assess your situation.

AngularJS (1.x) versus Angular (2+). If the bundle contains angular.module and $scope, it's AngularJS, and recovery is somewhat different because the code is plain ES5 with fewer compiler transformations—it's often more readable after beautification but lacks Ivy definitions to key off. The version check in Step 2 will tell you.

Standalone components and the modern builder. Angular 15+ standalone components appear as defineComponent calls without a surrounding defineNgModule, so your selector inventory comes from component definitions rather than module declarations. The esbuild-based builder also tends to produce output where templates are embedded similarly, so the reading method in Step 4 still applies.

Server-side rendering bundles. An SSR build adds a server bundle where the code is often less minified and sometimes closer to readable form. If you control deployment, the server artifact may be an easier recovery target than the client one.

FAQ

Can I ever get the exact original TypeScript back?

Only with a source map whose sourcesContent is populated. Even then, what you get is the pre-compilation source at the moment of that build, not any later edits. Without that, no—minification is lossy and some information is gone permanently.

Is un-minifying the same as decompiling?

No. Un-minifying restores formatting; it doesn't restore names or structure. Decompiling implies recovering higher-level logic, and for Angular bundles that means manual reading of compiler output as described in Step 4, not an automated decompiler.

Why do I see ɵɵ functions everywhere?

Those are Angular's Ivy instruction functions, the compiled form of templates and component definitions. Seeing them confirms the build is Ivy-era and is actually good news for recovery, because they preserve selector strings and binding structure.

Does a production Angular build ever include source maps by default?

The CLI's production configuration historically defaults source maps off, though this varies by builder and version, and teams can turn them on in angular.json. Never assume either way—check the files, and check the build config if you have the project.

What if the only artifact left is a single minified file with no map and no readable strings?

Then you have a behavior specification at best. Recover routes and selectors if any strings survive, extract CSS, and plan a rebuild rather than an extraction. That's a materially different project, and worth scoping honestly before starting.