Import Map Generator
Compose browser-native import maps with CDN-correct URLs, prefix mappings and scopes.
Mappings
2 entries · 0 scopesScopes
Generated import map
6 lines · 131 charsPut the import map script before any module scripts.
Details
An import map tells the browser how to resolve bare module specifiers such as react or lodash to URLs. This tool composes those mappings from entries you supply, using the correct URL convention for esm.sh, jsDelivr, unpkg or a local directory. Prefix mode emits a trailing slash on both key and URL so subpath imports resolve, and it warns when a CDN convention cannot support a prefix. Scopes let a URL prefix shadow a root mapping, which is useful for legacy zones. Duplicate specifiers are flagged and the JSON is withheld until they are fixed; you can also paste an existing map to edit it.
More examples
React without a bundler
react@18.3.1
react-dom/client@18.3.1With esm.sh selected, these entries produce an import map with two exact URLs. Copy the script tag and place it before your module scripts.
Prefix mapping for subpaths
d3@7.9.0 (prefix mode)Emits the key d3/ mapped to a slash-ended URL, so imports like d3/src/index.js resolve under the same package.
Legacy scope
lodash@4.17.21 at root
lodash@3.10.1 under https://example.com/legacy/The legacy scope overrides the root mapping only for modules loaded under that URL prefix.
Examples
React without a bundler
react@18.3.1, react-dom/client@18.3.1 on esm.sh{"imports":{"react":"https://esm.sh/react@18.3.1","react-dom/client":"https://esm.sh/react-dom/client@18.3.1"}}Copy the script tag and place it before any module scripts on the page.
Prefix for D3 subpaths
d3@7.9.0 with Prefix enabled"d3/": "https://esm.sh/d3@7.9.0/"Imports such as d3/src/index.js now resolve under the same pinned package.
Legacy scope
lodash@4.17.21 root, lodash@3.10.1 under https://example.com/legacy/"scopes": {"https://example.com/legacy/": {"imports": {"lodash": "https://esm.sh/lodash@3.10.1"}}}Only module graphs rooted under the legacy prefix see the older version.
About this tool
Import Map Generator authors the JSON that browsers use to resolve bare module specifiers. Add packages by name and version, or paste explicit URLs, and the tool composes an imports object using the URL convention of your chosen CDN: esm.sh, jsDelivr, unpkg or a local directory.
Prefix mappings are handled explicitly. A prefix entry emits a trailing slash on both the key and the value, which is what the HTML specification requires for subpath imports. Some CDN forms, such as unpkg query strings, cannot be prefix targets, so the tool falls back to a slash-ended URL and explains the change instead of silently producing a map that will not match.
Scopes let you override a root mapping for modules loaded under a particular URL prefix, which is useful for legacy zones or micro-frontends. Duplicate specifiers are detected and block emission; the same specifier inside a scope is allowed because shadowing is intentional. You can also paste an existing map back into the editor and edit it.
What this tool does not do
- The tool authors map JSON only; it does not verify that a CDN URL resolves or that a package version exists.
- Only one import map is emitted; multiplemaps support is version-dependent in browsers.
- Scopes accept one specifier override each in the editor; complex nested scope maps should be pasted in.
- Integrity metadata and es-module-shims fallback tags are not emitted.
- Versions in presets are snapshots and should be reviewed against upstream releases.
How to use this tool
Choose a CDN base
Pick esm.sh, jsDelivr, unpkg or a local path. The URL for every entry is recomposed immediately when you switch.
Add entries
Enter a bare specifier such as react or @babel/core and an optional pinned version. Use an explicit URL override when you need a custom build.
Toggle prefix mode
Enable Prefix for packages whose subpaths you import directly. The key becomes name/ and the URL ends with a slash.
Add scopes and copy
Optionally add a URL-prefix scope with a different version of the same package, then copy the JSON or the full script tag.
Use cases
No-build prototypes
Load React, Vue or Lit directly from a CDN without a bundler or install step.
Teaching ES modules
Show students exactly how bare specifiers resolve in a browser.
Micro-frontend zoning
Use scopes to pin different library versions per application zone.
Map round-tripping
Paste a map from documentation, adjust versions or scopes, and copy it back out.
CDN URL conventions
| Base | Exact URL |
|---|---|
| esm.sh | https://esm.sh/name@version |
| jsDelivr | https://cdn.jsdelivr.net/npm/name@version/+esm |
| unpkg | https://unpkg.com/name@version?module |
| local | base/name@version |
Prefix mode drops file transforms such as /+esm and ?module because those addresses cannot be slash-ended prefixes.
Common mistakes
Mistake:Mapping name to a URL but importing name/subpath.
Fix:Enable Prefix mode so the key ends with a slash and the URL is a directory.
Mistake:Putting a ?module URL in a prefix mapping.
Fix:The tool drops the query transform and warns; use an exact entry for that package.
Mistake:Placing the import map after module scripts.
Fix:Put the generated script tag before the first script type=module on the page.
Mistake:Declaring the same specifier twice in one mapping.
Fix:The tool flags duplicates and withholds the JSON until the conflict is removed.
Mistake:Leaving versions unpinned in production.
Fix:Pin a version for every entry; the tool warns on floating versions.
Frequently asked questions
What is the trailing slash for in import maps?
A key ending in / is a prefix mapping: it matches every specifier that starts with that text. The specification requires the mapped URL to end in / too, so browsers can append the rest of the subpath. Prefix mode in this tool applies the rule on both sides and warns when a CDN form cannot satisfy it.
How do scopes work?
A scope is a URL prefix. When a module loaded from that URL prefix imports a specifier, the browser checks the scope imports before the root imports. That lets two versions of the same package coexist: the root mapping serves the app, and a legacy scope pins an older version for a specific section.
Which browsers support import maps?
All current versions of Chrome, Edge, Firefox and Safari support import maps. Older Safari releases need a polyfill such as es-module-shims; the generated map JSON is compatible with that shim, but the tool does not emit the shim tag for you.
Can import maps be dynamic?
Only one import map is supported reliably in stable browsers, and it must be present before any module script is evaluated. Newer proposals allow multiple maps, but support is version-dependent, so this tool emits a single static map.
How do I use React without a bundler?
Load the React preset, copy the script tag, and place it before your module scripts. Then import React and react-dom/client by their bare specifiers inside a script type=module. Pin versions to avoid loading two different React copies.
Is it safe to use a CDN URL in production?
Import maps change which code the browser loads, so treat the URLs as part of your supply chain. Pin exact versions and use a CDN you trust. The tool never fetches package metadata or verifies URLs; it only composes strings.
Does this tool upload my configuration?
No. Composition, validation and export all happen in your browser tab. Nothing is sent to a server.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.