01What is Import Map Generator?
An import map is a JSON block inside <script type="importmap"> that tells the browser how to turn module specifiers such as "lit" or "app/utils.js" into URLs. This tool lets you write a map, check it against the HTML Standard, and test how a specifier will resolve before you ship the page. The validator follows the parsing algorithm in the standard. The top-level value must be a JSON object, and "imports", "scopes" and "integrity" must each be objects if present. Breaking those rules is a TypeError, so the browser rejects the whole map, and the tool shows it as an error. Any other top-level key, such as a typo like "import", is ignored by browsers and reported here as a warning. Each entry is normalized the way a browser does it. Keys that look like URLs, meaning they start with "/", "./" or "../" or parse as absolute URLs, are resolved against the page URL you enter. An empty key is dropped. An address that is not a string, or is a relative path without one of those prefixes, becomes null. A key ending in "/" whose address does not also end in "/" becomes null too. A null entry does not fail silently. It blocks resolution of that specifier, which is why each case gets a warning that names the entry. Scope prefixes are parsed as URLs against the page URL. Scopes and specifier keys are sorted in descending code unit order, so "/scope2/scope3/" is checked before "/scope2/". The normalized output panel shows the map in that order with full URLs, which is close to what the browser keeps in memory. The resolver box runs the standard's resolution steps. Enter a specifier and the URL of the script that imports it. With the scopes example loaded, resolving "b" from https://example.com/scope2/scope3/r.mjs gives https://example.com/b-3.mjs, while "a" from the same script falls back to the /scope2/ scope and gives /a-2.mjs. Prefix matches that climb above their mapped folder, such as "moment/../../evil.js", are blocked as the standard requires. A bare name with no entry, like "react", gets its own TypeError. For integrity entries, keys must resolve as URLs and values must be strings. The tool also warns when a value does not look like sha256-, sha384- or sha512- followed by base64. That format check is a light test of SRI metadata, not a full parser. Limits: the tool checks one map at a time and does not model how browsers merge several import maps on one page. It does not fetch the URLs, so a typo in a CDN path still passes. Everything runs locally in your browser.
Front-end developers loading ES modules without a bundler, and teams debugging module resolution errors in the browser. The tool runs entirely in your browser, so your data never leaves your device.
02How to use Import Map Generator
- Enter the URL of the page that will hold the import map
- Paste your import map JSON, or add mappings one at a time with the form
- Read the validation list and fix any errors or warnings
- Type a specifier and the referring script URL to see what it resolves to
- Copy the normalized map or the ready script tag
03Worked examples
- Input:
Map: {"imports":{"a":"/a-1.mjs","b":"/b-1.mjs","c":"/c-1.mjs"},"scopes":{"/scope2/":{"a":"/a-2.mjs"},"/scope2/scope3/":{"b":"/b-3.mjs"}}} Resolve "b" from https://example.com/scope2/scope3/r.mjs - Result:
https://example.com/b-3.mjs (scope "https://example.com/scope2/scope3/" exact match "b") - The same map resolves "b" from /scope2/r.mjs to https://example.com/b-1.mjs.
- Input:
Map with "lit" and "lit/" pointing at cdn.jsdelivr.net/npm/[email protected] Resolve "lit/decorators.js", then "react" - Result:
https://cdn.jsdelivr.net/npm/[email protected]/decorators.js (imports prefix match "lit/") TypeError: "react" is a bare specifier but was not remapped to anything by the import map. - Input:
Map: {"imports":{"moment":"/node_modules/moment/src/moment.js","moment/":"/node_modules/moment/src/"}} Resolve "moment/../../evil.js" - Result:
TypeError: resolution of "moment/../../evil.js" was blocked because it backtracks above its prefix "moment/". - Input:
{"imports":{"moment/":"/node_modules/moment/src/moment.js","helper":"node_modules/helper/index.mjs","":"/empty.js"},"integrity":{"/a.mjs":"md5-abc"},"import":{}} - Result:
imports "moment/": the key ends with "/", so the address must too (got "https://example.com/node_modules/moment/src/moment.js"). The entry becomes null and blocks resolution. imports "helper": address "node_modules/helper/index.mjs" is invalid. ... imports: specifier keys may not be the empty string. The entry is ignored. integrity "/a.mjs": "md5-abc" does not look like SRI metadata (sha256-, sha384- or sha512- followed by base64). Invalid top-level key "import". Only "imports", "scopes" and "integrity" are used. - All five are warnings; the second message is trimmed here.
- Input:
Page https://example.com/shop/index.html, map {"imports":{"app":"./js/app.mjs"},"integrity":{"./js/app.mjs":"sha384-oqVu...","foo":"sha256-x"}} - Result:
"app" resolves to https://example.com/shop/js/app.mjs integrity: key "foo" failed to resolve. Keys must be absolute URLs or start with "/", "./" or "../". The entry is ignored. - The integrity key is stored as https://example.com/shop/js/app.mjs. Hash trimmed.
- Input:
{"imports": []} - Result:
TypeError: the value for the "imports" top-level key needs to be a JSON object. - An error: browsers reject the whole map.
04Common use cases
- Checking an import map before adding it to a page that loads ES modules from a CDN
- Finding why a bare specifier like "lit/decorators.js" fails to resolve in the browser
- Testing which scope wins when several scope prefixes overlap
- Generating a <script type="importmap"> tag from a few specifier and URL pairs
- Reviewing integrity entries in an import map for malformed hash values
- Seeing what "./js/app.mjs" becomes when the map sits on a page in a subfolder like /shop/
05Tips
- Pair a bare mapping like "lit" with a trailing-slash mapping like "lit/" so both the main entry and subpaths resolve
- Relative addresses need a "./", "../" or "/" prefix; "js/app.js" alone is treated as invalid
- Change the referring script URL to test scopes, since scopes match on the importing script's URL
- A null entry blocks resolution instead of falling back, so fix every address warning
- Set the page URL to where the map really lives; "./" addresses resolve against it, not the site root
06Related concepts
ES modules, bare specifier, module specifier resolution, Subresource Integrity, import map scopes.
Frequently Asked Questions
What is Import Map Generator?
Import Map Generator is a free, browser-based developer tool on AIDToolStack. Create and check <script type="importmap"> JSON in your browser. See warnings the HTML Standard defines and resolve any specifier against your map. It requires no installation or sign-up and works entirely in your browser.
Is Import Map Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does Import Map Generator store my data?
No. It runs in your browser; nothing is uploaded.