.MJS

MJS File

Node.js ES Module File
Ask a question
QUICK ANSWER

An .mjs file is JavaScript source code that Node.js treats as an ECMAScript module, meaning it uses import and export instead of CommonJS require. The extension exists so Node can tell ES modules apart from older CommonJS files without checking package.json. Because it is plain text, you can open and edit an .mjs file in any code editor such as Visual Studio Code, Sublime Text, or Vim, and you run it with node file.mjs.

Developer: Node.js Foundation / OpenJS Foundation (Ecma International for ECMAScript) Category: Developer Files Open standard MIME: text/javascript
OPENS ON Windows macOS Linux Web
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Sep 10, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the MJS file format?

An .mjs file is JavaScript source code that Node.js loads as an ECMAScript module (ESM). The extension is a signal: any file ending in .mjs is treated as an ES module, using import and export statements, even when the project's package.json says nothing about module type.

Node.js added the extension in version 8.5.0 (2017), first behind the --experimental-modules flag, and made it stable in version 12. It exists to keep two module systems apart. Older Node code uses CommonJS with require() and module.exports, while modern code uses ESM. A plain .js file is CommonJS by default, so .mjs gives an unambiguous way to opt into modules. The matching .cjs extension forces CommonJS in the other direction.

Code in an .mjs file runs in strict mode automatically and can use top-level await and the import.meta object, neither of which works in CommonJS. Bundlers such as webpack, Rollup and Vite both read and write .mjs.

Security & safety

RISK: MEDIUM

An .mjs file is executable JavaScript. Running one with node executes whatever code it contains, so an untrusted .mjs file can perform harmful actions such as reading files or making network requests. Opening it in a text editor is safe; only run .mjs files from sources you trust, and review the code first.

Format details

in a nutshell
FULL NAMENode.js ES Module Fileaka Module JavaScript file, ES Module file
DEVELOPERNode.js Foundation / OpenJS Foundation (Ecma International for ECMAScript)since 2017 (Node.js v8.5.0)
MIME TYPEtext/javascript
TYPEPlain-text JavaScript source code
STANDARDOpen · royalty-free
This extension is also used by…
  • Generic minified JavaScript module - Some build tools emit .mjs to mark a bundled or minified ES module output rather than a hand-written source file.

Programs that open MJS files

Windows5 apps
Sublime Text Paid Open the file for fast editing; JavaScript syntax highlighting applies to .mjs.
Notepad Open-source Open the .mjs file to view and edit the raw source with lightweight syntax highlighting.
Visual Studio Code Free Open the .mjs file to edit it with ESM-aware syntax highlighting, IntelliSense and an integrated terminal for running node.
Node.js runtime Open-source Execute the module from a command prompt with 'node file.mjs'; the runtime loads it as an ES module.
WebStorm Paid Open the containing project to get full ESM refactoring, module resolution and debugging.
macOS5 apps
Sublime Text Paid Open the .mjs file for quick editing with JavaScript highlighting.
Vim Open-source Edit the file in the terminal with 'vim file.mjs'.
Visual Studio Code Free Open the file to edit with ESM IntelliSense and run it from the built-in terminal.
Node.js runtime Open-source Run 'node file.mjs' in Terminal to execute the module.
WebStorm Paid Open the project for module-aware editing, debugging and refactoring of .mjs files.
Linux4 apps
GNU Emacs Open-source Open the .mjs file with js-mode for editing.
Visual Studio Code Free Open the file for ESM-aware editing and run it from the integrated terminal.
Node.js runtime Open-source Execute 'node file.mjs' from a shell to run the module.
Vim / Neovim Open-source Edit the file in the terminal with JavaScript syntax support.
Web2 apps
Modern web browsers Free Load an .mjs file with <script type="module" src="app.mjs"> when the server sends a JavaScript MIME type.
StackBlitz Freemium Open or create .mjs modules in an in-browser Node.js environment and run them instantly.

Technical details

deep spec
EncodingUTF-8 plain text
Byte orderNot applicable (text file, no byte-order dependence; BOM optional but discouraged)
ContainerNone; raw JavaScript source
Typical sizeA few hundred bytes to tens of kilobytes per module
StructureHuman-readable JavaScript source using the ECMAScript module system. Uses static import and export statements, supports top-level await and import.meta, and runs in strict mode by default. Each .mjs file is a module with its own top-level scope; variables are not shared globally.
IntegrityNone built in; integrity is handled externally (npm package hashes, Subresource Integrity on the web, git).
PlatformsWindows, macOS, Linux, BSD, any OS running Node.js or a modern browser
NotesNode.js treats any .mjs file as an ES module regardless of the package.json "type" field, which is the main reason the extension exists. The counterpart .cjs forces CommonJS. Browsers can also load .mjs via <script type="module"> provided the server sends a JavaScript MIME type. Bundlers such as webpack, Rollup, esbuild and Vite read and emit .mjs.
Runs InNode.js runtime and modern web browsers (via script type=module)
Strict ModeAlways enabled; ES modules run in strict mode automatically
Released2017 (Node.js v8.5.0)
Latest versionECMAScript 2015 module system (stabilized in Node.js v12+)
Open standardYes · royalty-free
Specificationnodejs.org

MJS conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with MJS files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about MJS files.

Frequently asked questions

What is a .mjs file?
It is a JavaScript source file that Node.js loads as an ECMAScript module, using import and export instead of CommonJS require. The .mjs extension tells Node to treat the file as an ES module regardless of the package.json settings.
How do I open a .mjs file?
Open it in any code editor such as Visual Studio Code, Sublime Text or Vim, since it is plain text. To run it, use the command 'node file.mjs' with Node.js installed.
What is the difference between .mjs and .js?
A .mjs file is always an ES module. A .js file is CommonJS by default in Node.js, and only becomes an ES module when the project's package.json has "type": "module". The .mjs extension removes that ambiguity.
What is the difference between .mjs and .cjs?
The .mjs extension forces the ES module system (import/export), while .cjs forces CommonJS (require/module.exports). They let you mix both module systems in one project.
Can browsers run .mjs files?
Yes. A browser can load an .mjs file through a <script type="module"> tag, but the web server must serve it with a JavaScript MIME type such as text/javascript.
Is .mjs safe to open?
Opening it in an editor is safe because it is just text. Running it executes code, so only run .mjs files from trusted sources and review the contents first.

References

1MDN Web Docs - JavaScript modulesdeveloper.mozilla.org
2Node.js Documentation - Modules: ECMAScript modulesnodejs.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.NOMEDIAAndroid No-Media Marker File
6.PARTPartial Download File
7.RPMSGRestricted Permission Message
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z