# Source Map

> A file that links shrunk, built code back to the code you wrote.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** Sourcemap, .map file

## Think of it like

Think of it like a key on a treasure map. It tells you which squiggle on the page is which real place.

## Definition

A source map is a file that links built, shrunk code back to the original source you wrote. When an error happens in the bundle, the browser's tools use the map to show your real file and line. Without one, you would see one giant line of minified code. Build tools write the map next to each bundle. The bundle points to it with a comment at the end.

## Example

An error says line 1, column 48,213 of app.min.js. With the source map, the browser shows it is line 12 of cart.ts.

## Example code

```javascript
//# sourceMappingURL=app.min.js.map
```

The last line of a bundle points to its source map.

## Why it matters

It makes errors in real sites readable. Debugging without one is guesswork.

## Common mistake

Publishing source maps when your code is meant to stay private. They let anyone read the original.

## Three principles

- **Built to original.** Links shrunk code to yours.
- **Readable errors.** Real file and line numbers.
- **Think before you publish.** It exposes your source.

## Related terms

- [Minification](https://learn.benibix.com/term/development/minification)
- [JavaScript Bundler](https://learn.benibix.com/term/development/bundler)
- [Debugger](https://learn.benibix.com/term/development/debugger)
- [Transpiler](https://learn.benibix.com/term/development/transpiler)

---

Source: https://learn.benibix.com/term/development/source-map
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
