coderef

JSON import attributesBaseline · Newly available

Module import … with { type: "json" } statements load JSON data. Also known as JSON module scripts.

Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Apr 29, 2025.

Browser support

DesktopChrome
1–122Not supported
123+Supportedsince Mar 19, 2024
Current: 155
Edge
12–122Not supported
123+Supportedsince Mar 22, 2024
Current: 154
Firefox
1–137Not supported
138+Supportedsince Apr 29, 2025
Current: 157
Safari
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27
MobileChrome Android
18–122Not supported
123+Supportedsince Mar 19, 2024
Current: 155
Firefox Android
4–137Not supported
138+Supportedsince Apr 29, 2025
Current: 157
Safari iOS
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27

How to use

Every current browser supports this, but it only became Baseline on Apr 29, 2025. Use it as a progressive enhancement, or keep a fallback if you support older devices.

Example

Full syntax and examples are on MDN: with#json modules type json.

Feature detection

JS · check before using
// Syntax can't be tested with an if-statement — an unsupported
// browser fails to parse the whole script. Either transpile for older
// targets (e.g. Babel/TypeScript/esbuild), or probe in isolation:
let supported = true;
try {
  new Function("/* code that uses the syntax */");
} catch {
  supported = false;
}

This is a language syntax feature.

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
trailing_commas.trailing_commas_in_dynamic_import9191138159113815
import.import_attributes.type_json12312313817.212313817.2