Skip to content

Source maps

Decode JavaScript source maps and resolve minified stack positions to original source lines

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/sourcemap/index.md to help me query Source maps with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Decode a source map into its full token (mapping) table.

Example output · captured
Connector release
v0.5.1
Engine
2.0.1
VGI protocol
3.4.0
SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')
Result
gen_line gen_col source
0 0 index.js

Quick start

Choose where to run Source maps, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'sourcemap' AS sourcemap (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-sourcemap'
);

3. Run a query

query.sql
SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')
More example queries →
Technical details
Verified connector release
v0.5.1
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'sourcemap' AS sourcemap (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Decode JavaScript Source Map v3 (.map) files and resolve minified positions back to original source locations.

Catalog

Everything sourcemap exposes once attached — read straight from the worker's released build.

sourcemap 1 schema
main 1 view · 6 functions

Source Map v3 decoding and minified-position resolution functions.

Schema examples (7)
Examples (7)

Decode a source map into its full token (mapping) table.

SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');
Result
gen_line gen_col source
0 0 index.js

Resolve a minified (line, col) position to its original source location.

SELECT sourcemap.main.lookup('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}', 0, 0);

List the original source files a map references.

SELECT src_id, source, has_content
FROM sourcemap.main.sources('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');

Read a map's version and mapping counts.

SELECT version, n_sources, n_mappings
FROM sourcemap.main.meta('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');
3 more examples

De-minify a batch of error frames with lookup_all, then join sources() and use source_content() to show the original line of code each frame lands on (orig_line is 1-indexed).

WITH frames(id, line, col) AS (VALUES (1, 0, 30), (2, 1, 20), (3, 0, 40)) SELECT r.id, r.source, r.src_line + 1 AS orig_line, r.name, trim(string_split(sourcemap.main.source_content('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', s.src_id), chr(10))[r.src_line + 1]) AS code
FROM sourcemap.main.lookup_all((SELECT id, line, col FROM frames), map := '{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', id := 'id') AS r
JOIN sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s ON s.source = r.source
ORDER BY r.id;

List each original file that embeds its source text, with that text's line and character counts, by feeding each sources() src_id into source_content().

SELECT src_id, source,
  len(string_split(rtrim(content, chr(10)), chr(10))) AS n_lines,
  length(content) AS n_chars
FROM (SELECT s.src_id, s.source, sourcemap.main.source_content('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', s.src_id) AS content FROM sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s WHERE s.has_content)
ORDER BY src_id;

Count the decoded mappings (and distinct symbol names) pointing into each original file by LEFT JOINing tokens() onto sources(), so a file with zero mappings (tree-shaken code) still appears with a count of 0.

SELECT s.source, count(t.gen_col) AS n_mappings,
  count(DISTINCT t.name) AS n_names
FROM sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s
LEFT JOIN sourcemap.main.tokens('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS t ON t.src_id = s.src_id
GROUP BY s.src_id, s.source
ORDER BY s.src_id;
Views
example_tokens 2 examples7 cols

A worked example: the decoded token (mapping) rows of a tiny built-in sample source map, so you can see the shape of tokens(map) output without supplying a map.

Columns
gen_line BIGINT
0-indexed generated (minified) line of this mapping.
gen_col BIGINT
0-indexed generated (minified) column of this mapping.
src_id BIGINT
0-based index into sources() of the original file, or NULL if the token has no source.
source VARCHAR
Original source file path this mapping points at, or NULL.
src_line BIGINT
0-indexed original source line number (0 = the first line), or NULL.
src_col BIGINT
0-indexed original source column number (0 = the first column), or NULL.
name VARCHAR
Original symbol name for this mapping, or NULL if none.
Examples (2)

Preview the decoded token rows of the built-in sample map.

SELECT gen_line, gen_col, source FROM sourcemap.main.example_tokens;

Count how many decoded mappings the sample map contains.

SELECT count(*) AS n FROM sourcemap.main.example_tokens;
Link
Scalar functions
lookup (map ANY, gen_line BIGINT, gen_col BIGINT) 1 example

Resolve a minified (gen_line, gen_col) position to its original STRUCT(source, src_line, src_col, name) using nearest-preceding source-map semantics; NULL if the map is missing/malformed or the position precedes the first mapping

Arguments
map ANY
The source map: a path to a .map file, the raw map JSON text, or the map bytes. Read per row, so it may vary per row (e.g. a column of map paths or map bodies).
gen_line BIGINT
The 0-indexed generated (minified) line to resolve.
gen_col BIGINT
The 0-indexed generated (minified) column to resolve.
ReturnsSTRUCT of 4 fields
STRUCT 4 fields
  • sourceVARCHAR
  • src_lineBIGINT
  • src_colBIGINT
  • nameVARCHAR
Example

Resolve a generated line/column back to its original location.

SELECT sourcemap.main.lookup('{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA"}', 0, 0);
Link
source_content (map ANY, src_id BIGINT) 1 example

Return the inline sourcesContent of one original source (by src_id) embedded in the map, or NULL if absent

Arguments
map ANY
The source map: a path to a .map file, the raw map JSON text, or the map bytes.
src_id BIGINT
The 0-based source id whose inline content to return (matches sources.src_id).
ReturnsVARCHAR
Example

Fetch the embedded original source text for source 0.

SELECT sourcemap.main.source_content('{"version":3,"sources":["a.js"],"sourcesContent":["const x = 1;"],"names":[],"mappings":"AAAA"}', 0);
Link
Table functions
meta (map ANY) 1 example

Return one row of source-map metadata (version, file, counts)

Arguments
map ANY
The source map: a path to a .map file, the raw map JSON text, or the map bytes.
Returns columns
version BIGINT
Source Map spec version (always 3).
file VARCHAR
The generated (minified) file the map describes, or NULL if unset.
source_root VARCHAR
The map's sourceRoot prefix, or NULL if unset.
n_sources BIGINT
Number of original source files the map references.
n_names BIGINT
Number of original symbol names the map carries.
n_mappings BIGINT
Number of decoded tokens (after flattening any index-map sections).
Example

Read version, source count, and mapping count from an inline map.

SELECT version, n_sources, n_mappings
FROM sourcemap.main.meta('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');
Link
sources (map ANY) 2 examples

List the original sources of a source map (with inline-content flag)

Arguments
map ANY
The source map: a path to a .map file, the raw map JSON text, or the map bytes.
Returns columns
src_id BIGINT
0-based source index (feed it to source_content(map, src_id) to fetch this file's embedded text).
source VARCHAR
Original source file path, with the map's sourceRoot already joined on.
has_content BOOLEAN
Whether the map embeds this source's text inline via sourcesContent.
Examples (2)

List the original source files referenced by an inline map.

SELECT src_id, source, has_content
FROM sourcemap.main.sources('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');

List each original file that embeds its source text, with that text's line and character counts, by feeding each sources() src_id into source_content().

SELECT src_id, source,
  len(string_split(rtrim(content, chr(10)), chr(10))) AS n_lines,
  length(content) AS n_chars
FROM (SELECT s.src_id, s.source, sourcemap.main.source_content('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', s.src_id) AS content FROM sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s WHERE s.has_content)
ORDER BY src_id;
Link
tokens (map ANY) 2 examples

Decode a source map into its full token (mapping) table

Arguments
map ANY
The source map to decode: a path to a .map file, the raw map JSON text, or the map bytes.
Returns columns
gen_line BIGINT
0-indexed generated (minified) line of this mapping.
gen_col BIGINT
0-indexed generated (minified) column of this mapping.
src_id BIGINT
0-based index into sources() of the original file, or NULL if the token has no source.
source VARCHAR
Original source file path this mapping points at, or NULL.
src_line BIGINT
0-indexed original source line, or NULL.
src_col BIGINT
0-indexed original source column, or NULL.
name VARCHAR
Original symbol name for this mapping, or NULL if none.
Examples (2)

Explode an inline source map into its decoded token rows.

SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}');
Result
gen_line gen_col source
0 0 index.js

Count the decoded mappings (and distinct symbol names) pointing into each original file by LEFT JOINing tokens() onto sources(), so a file with zero mappings (tree-shaken code) still appears with a count of 0.

SELECT s.source, count(t.gen_col) AS n_mappings,
  count(DISTINCT t.name) AS n_names
FROM sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s
LEFT JOIN sourcemap.main.tokens('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS t ON t.src_id = s.src_id
GROUP BY s.src_id, s.source
ORDER BY s.src_id;
Link
Table in-out functions
lookup_all (frames TABLE, map := ANY, id := VARCHAR, line := VARCHAR, col := VARCHAR) 2 examples

Bulk-resolve a column of minified frames against one map (id passthrough)

Positional arguments
frames TABLE
The input relation of minified frames, supplied as a subquery, e.g. `(SELECT id, line, col FROM frames)`. Must contain the id/line/col columns named by the `id`/`line`/`col` arguments.
Named arguments
map := ANY
The single source map applied to every input row: a path to a .map file, the raw map JSON text, or the map bytes.
id := VARCHAR
Name of the input column to pass through to the output unchanged (so results join back to the source row). Default 'id'.
line := VARCHAR
Name of the input column holding the 0-indexed generated line. Default 'line'.
col := VARCHAR
Name of the input column holding the 0-indexed generated column. Default 'col'.
Returns columns
id BIGINT
Passthrough of the input id column (same name and type as the input).
source VARCHAR
Original source file, or NULL when the frame does not resolve.
src_line BIGINT
0-indexed original line, or NULL when unresolved.
src_col BIGINT
0-indexed original column, or NULL when unresolved.
name VARCHAR
Original symbol name, or NULL if the mapping carries none.
Returns columns · depends on the arguments
id BIGINT
Passthrough of the input id column (same name and type as the input).
source VARCHAR
Original source file, or NULL when the frame does not resolve.
src_line BIGINT
0-indexed original line, or NULL when unresolved.
src_col BIGINT
0-indexed original column, or NULL when unresolved.
name VARCHAR
Original symbol name, or NULL if the mapping carries none.
Examples (2)

Resolve a column of frames against one inline map, joining back by id.

SELECT r.id, r.source, r.src_line
FROM sourcemap.main.lookup_all((SELECT * FROM (VALUES (1, 0, 0)) AS f(id, line, col)), map := '{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}', id := 'id') AS r;

De-minify a batch of error frames with lookup_all, then join sources() and use source_content() to show the original line of code each frame lands on (orig_line is 1-indexed).

WITH frames(id, line, col) AS (VALUES (1, 0, 30), (2, 1, 20), (3, 0, 40)) SELECT r.id, r.source, r.src_line + 1 AS orig_line, r.name, trim(string_split(sourcemap.main.source_content('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', s.src_id), chr(10))[r.src_line + 1]) AS code
FROM sourcemap.main.lookup_all((SELECT id, line, col FROM frames), map := '{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', id := 'id') AS r
JOIN sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s ON s.source = r.source
ORDER BY r.id;
Link

Try these queries

Resolve a minified (line, col) position to its original source location.

SELECT sourcemap.main.lookup('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}', 0, 0)

Uses lookup

List the original source files a map references.

SELECT src_id, source, has_content
FROM sourcemap.main.sources('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')

Uses sources

Read a map's version and mapping counts.

SELECT version, n_sources, n_mappings
FROM sourcemap.main.meta('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')

Uses meta

De-minify a batch of error frames with lookup_all, then join sources() and use source_content() to show the original line of code each frame lands on (orig_line is 1-indexed).

WITH frames(id, line, col) AS (VALUES (1, 0, 30), (2, 1, 20), (3, 0, 40)) SELECT r.id, r.source, r.src_line + 1 AS orig_line, r.name, trim(string_split(sourcemap.main.source_content('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', s.src_id), chr(10))[r.src_line + 1]) AS code
FROM sourcemap.main.lookup_all((SELECT id, line, col FROM frames), map := '{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}', id := 'id') AS r
JOIN sourcemap.main.sources('{"version":3,"file":"app.min.js","sources":["src/index.js","src/util.js","src/unused.js"],"sourcesContent":["function main() {\n  console.log(add(1, 2));\n}\nmain();\n","function add(a, b) {\n  return a + b;\n}\n","function unused() {\n  return 0;\n}\n"],"names":["main","console","log","add"],"mappings":"AAAA,SAASA,OACPC,QAAQC,IAAIC,UAEdH;ACHA,SAASG,SACP"}') AS s ON s.source = r.source
ORDER BY r.id

Uses source_contentsourceslookup_all

Preview the decoded token rows of the built-in sample map.

SELECT gen_line, gen_col, source FROM sourcemap.main.example_tokens

Uses example_tokens

Resolve a column of frames against one inline map, joining back by id.

SELECT r.id, r.source, r.src_line
FROM sourcemap.main.lookup_all((SELECT * FROM (VALUES (1, 0, 0)) AS f(id, line, col)), map := '{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}', id := 'id') AS r

Uses lookup_all

5 more examples in the Catalog, each listed under the table or function it uses.

Source maps is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.