1. Home
  2. Developer tools
  3. Source Map Decoder

Source Map Decoder

An error from production points at line 1, column 8,421 of a minified bundle. Open the source map, paste the stack trace, and see which original file, line and function it came from.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Source Map Decoder

  1. Paste or open the source map.
  2. Paste the stack trace.
  3. Read the original positions and source lines.

Features

  • Reads version 3 source maps
  • Parses Chrome and Firefox or Safari stack frames
  • Original file, line, column and name
  • Shows the source line when sourcesContent is present
  • Single position lookup
  • Counts sources, names and mapping segments

Supported formats

Input

  • Source map
  • Stack trace

You get

  • Original positions

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Source Map Decoder is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Index maps with sections are not supported; use the map of a single bundle.
  • A map must match the exact build that produced the stack trace.

Guide

Mapping minified stack traces back to source with a source map

Production JavaScript is minified: names are shortened, lines are joined and a whole application can live on one line of a file. When an error comes from such a file, the stack trace says only line 1, column 8,421. A source map is the file that records how each position in the generated code relates to the original source, and with it a trace can be turned back into names and lines a person recognises.

What is inside a source map

A source map is a JSON file. Its fields include version (3), file (the generated file), sources (the list of original files), names (identifiers that were renamed), sourcesContent (optionally the original code) and mappings. The mappings string is the compact part. Generated lines are separated by semicolons and segments within a line by commas. Each segment is up to five numbers in Base64 VLQ form: the column in the generated line, the index of the source, the original line, the original column and optionally an index into names.

Decoding the mappings

Variable-length quantities store small numbers in few characters. Each Base64 character carries five bits of value and a continuation bit, and the lowest bit of the result is the sign. All numbers except the generated column are deltas from the previous segment, and the generated column resets with every line. The decoder in the page expands the whole string into a table of segments and reports how many there are, which is a quick sanity check for a map that may be damaged.

Looking up a position

For a position in the generated file, the lookup finds the last segment on that line that starts at or before the column. That segment tells you the source file, line and column, and the name if there is one. Stack traces count lines and columns from 1 while the map counts from 0, so the page subtracts one for you. Paste the trace, and every frame is resolved; you can also type a single line and column into the lookup box.

Stack formats

Chrome and Node print frames as “at fn (https://example.com/app.min.js:1:32)”. Firefox and Safari print “fn@https://example.com/app.min.js:1:32”. The page reads both and resolves each frame against the map you pasted, so use a map that matches the file in the trace; frames from other scripts will map to wrong places or to nothing. A frame with no mapping is shown as “no mapping at this position”.

A worked example

The Sample button loads a small map for app.min.js with one source, src/math.js, two names, eight segments and the source included. The trace has two frames. The first frame, d at 1:32, resolves to src/math.js:2:22, which is the new Error call on line 2, and the original line “if (b === 0) throw new Error(‘Divide by zero’);” is displayed. The second, r at 1:84, resolves to src/math.js:7:3, the line return divide(10, 0);. The position 1:17 points at 2:3, the start of the if statement, and 1:1 maps to 1:8 with the name divide.

Limits

Only a single, plain version 3 map is read. Index maps with sections, maps in other versions and maps embedded as data URLs need separate handling. The page can resolve a position only as precisely as the map allows; minifiers may map a whole expression to one point. The map must come from the same build as the file in the trace, and the page never downloads anything, so you supply both texts yourself.

Checked against the current version of the Source Map Decoder on .

Frequently asked questions

How do I find the source map for a file in production?

Look at the last line of the minified file for a comment beginning with sourceMappingURL. It names the map file, usually the same name with .map added. If the comment is missing, the build did not publish the map, and you need the one produced by that exact build.

Is it safe to paste a source map from my own project?

The page decodes it in your browser and does not upload it. The map often includes your original source code, so keep it private and avoid pasting maps from other people’s projects, or any file you do not have the right to read.

Why do my positions look off by one?

Stack traces count lines and columns from 1 while source maps count from 0. This page converts for you, so give it the numbers exactly as they appear in the trace.

Is my source code uploaded?

No. The map, which may contain your original source, is decoded locally and is not sent anywhere.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.