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
- Query Farm hosting
- Available · $10/month organization minimum
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"}')
| 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.
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;
INSTALL vgi FROM community;
LOAD vgi;
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'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'sourcemap' AS sourcemap (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-sourcemap:0.5.1'
);
3. Run a query
SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'sourcemap' AS sourcemap
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')
Query Farm operates Source maps for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use sourcemap as the catalog alias for the query below.
4. Run a query
SELECT gen_line, gen_col, source
FROM sourcemap.main.tokens('{"version":3,"file":"o.js","sources":["index.js"],"names":[],"mappings":"AAAA"}')
Technical details
- Verified connector release
- v0.5.1
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
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]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'sourcemap' AS sourcemap (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-sourcemap:0.5.1'
);
Overview
Decode JavaScript Source Map v3 (.map) files and resolve minified positions back to original source locations.
Decode JavaScript Source Map v3 (.map) files and resolve minified (line, col) positions back to original source:line:col:name, directly in DuckDB SQL. Nothing else in DuckDB reads source maps — read_json gives you the wrapper object but not the decoded Base64-VLQ mappings grammar. This worker performs that decode and exposes both the raw mapping rows and resolved original positions, so a column of production RUM / error-tracking frames can be de-minified in bulk with a single JOIN.
The heavy lifting (Base64-VLQ decode, index maps via sections, inline sourcesContent, the nearest-preceding lookup) is done by the Sentry sourcemap crate; this worker is a thin Arrow adapter over it. A map is supplied as a path to a .map file, the raw map JSON text (e.g. (SELECT content FROM read_text(...))), or map BLOB bytes — so data-URI inline maps decode via the text/bytes mode.
Semantics
- All line/column numbers are 0-indexed (Source Map v3); browser stack frames are usually 1-indexed, so subtract one before resolving.
- Position resolution is nearest-preceding (the greatest mapping
<=the requested position), so an exact(line, col)match isn't required. - Per-row resolution is tolerant: a NULL, malformed, or empty map — or a position with no match — yields NULL rather than failing the query, so one bad frame never aborts a scan.
When to use
Reach for it whenever you have minified positions (deployed bundle line/column) and the corresponding source map, and you want the original file, line, column, and symbol name back — one frame at a time or a whole error table at once.
Sources and references
- ECMA-426 Source map format specification — the standardized Source Map v3 format (
mappings,sources,names, index-mapsections) this worker decodes. - Sentry
sourcemapcrate (API docs) — the decoder and lookup engine the worker wraps.
Catalog
Everything sourcemap exposes once attached — read straight from the worker's
released build.
main 1 view · 6 functions
Source Map v3 decoding and minified-position resolution functions.
Schema 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"}');
| 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;
example_tokens
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.
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;
lookup (map ANY, gen_line BIGINT, gen_col BIGINT)
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
-
sourceVARCHAR
-
src_lineBIGINT
-
src_colBIGINT
-
nameVARCHAR
Resolve a generated line/column back to its original location.
SELECT sourcemap.main.lookup('{"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA"}', 0, 0);
source_content (map ANY, src_id BIGINT)
Return the inline sourcesContent of one original source (by src_id) embedded in the map, or NULL if absent
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);
meta (map ANY)
Return one row of source-map metadata (version, file, counts)
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"}');
sources (map ANY)
List the original sources of a source map (with inline-content flag)
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;
tokens (map ANY)
Decode a source map into its full token (mapping) table
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"}');
| 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;
lookup_all (frames TABLE, map := ANY, id := VARCHAR, line := VARCHAR, col := VARCHAR)
Bulk-resolve a column of minified frames against one map (id passthrough)
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;
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
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.
Related workers
ASN.1
File formats & encodings
Decode ASN.1 BER/DER blobs and SNMP, Kerberos, LDAP, CMS, PKCS and OCSP messages into SQL rows
BSON
File formats & encodings
Query BSON documents and move them between files and tables
CBOR
File formats & encodings
Decode and encode CBOR and MessagePack, inspect security payloads, and import or export row files from SQL