ECMAScript JavaScript module source file used by Node.js and modern web browsers
File type: Source code and script file
An MJS file is a plain-text JavaScript source file written as an ECMAScript module (ES module). It can contain import and export statements, allowing code to be organized into reusable modules.
Node.js opens and executes MJS files using its native ES module system. Modern browsers can also load them when referenced with a script element using type="module". Source-code editors and integrated development environments such as Visual Studio Code, Sublime Text, and WebStorm can edit them.
File type category:
Source code and script file
Date updated: August 11, 2026
MJS files contain UTF-8-compatible text with standard ECMAScript syntax. The .mjs suffix explicitly identifies the file as an ES module in Node.js, so Node.js interprets its imports, exports, and module-related behavior accordingly.
In Node.js, a .js file may be treated as either an ES module or a CommonJS script depending on the nearest package.json file and its type setting. An .mjs file is consistently treated as an ES module, making the format useful when a project needs an unambiguous module designation.
The extension became widely used as JavaScript gained standardized module support and Node.js adopted native ES modules. Current versions of Node.js and modern browsers support the core module features, although browser files generally must be served from a web server with an appropriate JavaScript MIME type rather than opened directly from the local file system.
MJS files can be edited on Windows, macOS, and Linux with text editors and development environments including Visual Studio Code, WebStorm, and Vim. They can be executed with Node.js or processed by build tools such as Rollup, webpack, and esbuild.
To run an MJS file with Node.js, install Node.js and execute the file from a terminal with the Node command. Its imported modules must use valid paths or package names, and local imports commonly include their file extensions. On Windows, macOS, and Linux, you can open or edit the file with Visual Studio Code, WebStorm, Sublime Text, or another plain-text editor.
For browser use, reference the file with a script element configured as type="module" and serve it through a local or web server. A browser usually will not execute an MJS file correctly if it is opened directly as a file, and server configuration must provide a JavaScript-compatible MIME type.
MJS files are source code, so they are not normally converted like documents or images. To produce browser-compatible or older JavaScript, use desktop tools such as Babel, TypeScript, esbuild, Rollup, or webpack to transpile, bundle, or minify the module. These tools may output .js files, bundled files, or other deployment assets.
Changing .mjs to .js can be done by renaming the file, but it is safe only when the destination environment is configured to interpret the code as an ES module and the module syntax is supported. Converting CommonJS JavaScript to ES module syntax may require code changes. Browser-based transpilers and JavaScript minification services can process MJS source, but source code should not be uploaded to online services if it contains confidential information.
Software applications that can open mjs files:
Multiplatform
Software applications that handle other tasks involving mjs files:
Multiplatform