Course contentsShow
← JavaScript
Lesson 2476 of 2,72350. JavaScript Build ToolingFree lesson

Source Map File Structure

Understand the .map file format, including version, sources, mappings, and sourceContent fields.

Source Map File Structure

You'll learn: The anatomy of a .map file and what each field tells the debugger about your original code.

A source map is a JSON file that acts like a Rosetta Stone, translating minified/bundled JavaScript back to your original source code. Understanding its structure helps you debug mapping issues and appreciate what your build tools generate.

The Five Key Fields

When you open a .map file, you'll find a JSON object with these critical properties:

version: Always 3 — the current source map specification version. This tells tools how to parse the rest of the file.

sources: An array of original file paths (e.g., ["src/utils.js", "src/main.js"]). These are the files you actually wrote, before bundling.

mappings: The magic string! A Base64 VLQ-encoded sequence that maps each position in the minified code to positions in the original sources. Think of it as GPS coordinates connecting every semicolon and variable in the bundle back to its birthplace.

sourceContent: An optional array containing the actual text of your original files. This lets debuggers show your source code even if the original files aren't deployed to production.

names: An array of original variable and function names before minification. For example, ["calculateTotal", "userInput"] instead of ["a", "b"].

The Anatomy in Action

{
  "version": 3,
  "sources": ["src/app.js"],
  "names": ["sum", "a", "b"],
  "mappings": "AAAA,SAASA,EAAI...",
  "sourceContent": ["function sum(a, b) { return a + b; }"]
}

The mappings field is the complex one — it's compressed to save space, but bundlers generate it automatically for you.

Key Takeaway: A source map's structure bridges minified code to originals through sources (file paths), mappings (position data), names (identifiers), and optionally sourceContent (actual source text), all versioned at 3.