Import Map Parser

Parse imports and scopes from import-map JSON into portable entries, preserving null addresses and leaving URL resolution to the caller.

Description

Import maps associate module specifiers with addresses and may define scope-specific mappings.

Import maps associate module specifiers with addresses and may define scope-specific mappings. A null address can block a mapping rather than naming a resource.1

Parse imports and scopes from import-map JSON into portable entries, preserving null addresses and leaving URL resolution to the caller.

When to use Import Map Parser

Use this tool to parse imports and scopes from import-map JSON into portable entries, preserving null addresses and leaving URL resolution to the caller.

Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.

How to use Import Map Parser and understand its results

  1. Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.
  2. Enter json using the field table and calculation rules, then run the tool.
  3. Read imports, scopes. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
jsonImport-map JSON object.string; maximum length: 1000000Required

Paste a JSON object. Parse imports and each scope mapping as objects whose nonempty specifier keys map to strings or null. Return ordered portable records, preserving null addresses; omitted imports/scopes become empty lists. Other top-level members are ignored.

imports=entries(map.imports or {}); scopes=entries(map.scopes or {})

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
importsTop-level specifier mappings.list of object; minimum entries: 0; maximum entries: 100000
scopesScoped specifier mappings.list of object; minimum entries: 0; maximum entries: 100000
json
{
  "input": {
    "json": "{\"imports\":{\"lib\":\"/lib.js\",\"blocked\":null},\"scopes\":{\"/app/\":{\"lib\":\"/v2.js\"}}}"
  },
  "output": {
    "imports": [
      {
        "specifier": "lib",
        "address": "/lib.js"
      },
      {
        "specifier": "blocked",
        "address": null
      }
    ],
    "scopes": [
      {
        "scope": "/app/",
        "imports": [
          {
            "specifier": "lib",
            "address": "/v2.js"
          }
        ]
      }
    ]
  }
}

Limitations and assumptions

This does not resolve URLs, normalize or sort scope prefixes, enforce trailing-slash matching or implement module resolution. It neither fetches modules nor validates every browser import-map restriction.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use ModulepreloadDetector: Extract modulepreload link hints from HTML source without fetching, validating browser support, or resolving their hrefs. For a complementary task, use URL Is Relative: Check whether a reference needs a base URL and resolves against a hierarchical HTTPS base.

References

  1. Import Map Parser — tool.io

Similar or alternative tools

  • ModulepreloadDetector

    Extract modulepreload link hints from HTML source without fetching, validating browser support, or resolving their hrefs.

  • URL Is Relative

    Check whether a reference needs a base URL and resolves against a hierarchical HTTPS base.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies