Using Source Maps in Browser DevTools
You'll learn how to debug minified production code by viewing the original source files and accurate line numbers in your browser's developer tools.
What This Solves
When your production JavaScript is minified or transpiled, debugging becomes nearly impossible—error stack traces point to meaningless locations in compressed code. Source maps act as a bridge, letting DevTools show you the original code you wrote, even though the browser is executing the transformed version.
Enabling Source Maps in DevTools
Most modern browsers automatically detect and load source maps when they're referenced in your bundled JavaScript (via a special comment or HTTP header). You typically don't need to configure anything—if your build tool generates source maps and references them correctly, DevTools will find them.
Debugging with Source Maps
Once loaded, source maps transform your debugging experience:
- Original file names appear in the Sources panel instead of
bundle.min.js - Line numbers match your source code, not the minified output
- Breakpoints work as if you were running unbundled code
- Stack traces in the console show readable function names and accurate locations
- Variable names remain meaningful during step-through debugging
For example, an error that would show at e (bundle.js:1:4523) now displays at validateUser (src/auth.js:42).
Inspecting Source Map Status
In Chrome/Edge DevTools, right-click a source file in the Sources panel to see if a source map is loaded. In Firefox, check the Debugger panel's file tree. If original sources don't appear, verify your bundler configuration and that .map files are accessible.
Key Takeaway: Source maps let you debug minified production code as if it were your original, unminified source—all error messages, breakpoints, and stack traces point to the code you actually wrote, making production debugging dramatically easier.