Import assertions
Import assertions attach explicit type metadata to module imports. They help runtimes and tooling interpret non-JavaScript modules more safely and predictably.
Overview
Import assertions attach explicit type metadata to module imports. They help runtimes and tooling interpret non-JavaScript modules more safely and predictably.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
javascript.statements.import.import_assertions Deprecated Non-standard | 91 | 91 | | | 91 | |
| Statement | ||||||
import assertions.type css Deprecated Non-standard `assert {type: 'css'}` | 93 | 93 | | | 93 | |
import assertions.type json Deprecated Non-standard `assert {type: 'json'}` | 91 | 91 | | | 91 | |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Notes 1 item(s)
Removed
- This feature was removed in a later browser version (126)
Syntax
JAVASCRIPT
import data from './data.json' with { type: 'json' };
import styles from './styles.css' with { type: 'css' }; Use cases
Typed JSON imports
Mark imported data as JSON so the loader knows exactly how it should be interpreted.
Safer module boundaries
Keep asset imports self-describing in larger codebases with multiple module types.
Cautions
- Support and syntax have evolved, so match the import form to the runtimes and bundlers you actually target.
- Typed imports improve clarity, but they do not replace validation of untrusted data.
Accessibility
- No direct accessibility effect, though clearer module boundaries can reduce implementation mistakes in user-facing content.
- If imported assets include labels or messages, preserve their localization and accessibility review path.
Related links
Powered by web-features