.MJS file extension
To open .MJS files on Windows, to view or edit: right-click the .mjs file → Open with → choose a code editor (any plain-text editor works).
To open a .mjs file, use a code editor (to read or edit the source) or run it with Node.js as an ECMAScript module. Don’t rename it to .js unless you also understand how your runtime or project determines module vs. CommonJS behavior.
Last updated: June 11, 2026 · Reviewed by Julian Stricker
What “reviewed” means on this page
- Format fit: whether the “what is this file?” description matches common real-world use of the extension, including category, typical MIME types, and aliases.
- Opening paths: whether Windows / macOS / Linux steps read plausibly for current OS dialogs and default apps; we remove fantasy menus and unsafe shortcuts.
- Security framing: whether risk notes match the extension class (for example executables vs plain data) and whether affiliate wording does not contradict the security section.
- Sources and further reading: whether external links point to vendors, standards bodies, or other primary references where possible; we avoid inventing details we cannot ground.
- Limits: this is clarity and safety-messaging QA, not a guarantee that every statement is exhaustive or that every binary you download is harmless.
Full methodology in the Imprint — The Imprint also states where AI is used and what that does—and does not—replace.
Open on your device
Choose your operating system for a dedicated step-by-step opening guide.
How to open .MJS files
Use these platform-specific instructions to open .MJS files safely.
Windows
- To view or edit: right-click the .mjs file → Open with → choose a code editor (any plain-text editor works).
- To run with Node.js: open Command Prompt/PowerShell, go to the file’s folder, and run: node yourfile.mjs.
Mac
- To view or edit: Control-click the .mjs file → Open With → choose a code editor (or any text editor).
- To run with Node.js: open Terminal, cd to the file’s folder, and run: node yourfile.mjs.
Linux
- To view or edit: open the file in a text editor from your file manager (Open With → a code editor).
- To run with Node.js: open a terminal in the file’s folder and run: node yourfile.mjs.
iOS
- iOS can store and display plain text, but running .mjs is not typical; open it as text in the Files app or transfer it to a desktop to run with Node.js.
Android
- Android can open .mjs as plain text in an editor app, but running it is not typical; for execution, transfer the file to a desktop environment with Node.js.
Security notes
- .mjs files are executable code when run in a JavaScript runtime (for example, Node.js). Only execute .mjs files you trust, because they can read/write files or make network requests depending on what the script does.
- If you only need to inspect the contents, open the .mjs file in a text editor rather than running it.
- Be cautious with .mjs files from unknown sources that claim to be “documents”—they are typically source code modules, not safe-to-render document formats.
Before you run downloaded code
These files usually need a runtime (Python, Node, Java, …). They are not classic “file viruses,” but untrusted code can still do serious harm if you execute it. Prefer official packages, verify publishers, and scan archives or sketchy downloads when you are unsure.
Avast offers free and premium antivirus software that protects against viruses, malware, ransomware, and phishing. Scan files before opening them to ensure safety.
NortonNorton 360 delivers comprehensive antivirus protection, VPN, and identity theft monitoring. Scan files for threats before opening to keep your device secure.
We may earn a commission when you use affiliate links. This supports our free file extension guides.
Can't open this file?
These are the most common causes and fixes when .MJS files fail to open.
Common reasons
- The file opens as plain text or “unknown file type”
- Node.js errors about modules (import/export not working)
- Web/server MIME type problems when hosting .mjs
Fix steps
- Open it with a code editor or any plain-text editor using “Open with”.
- If you work with .mjs frequently, set your preferred editor as the default app for this extension.
OS-specific troubleshooting
What is a .MJS file?
An .mjs file contains JavaScript source code intended to be treated as an ECMAScript module (ESM). RFC 9239 notes that the .mjs extension signals the file represents a JavaScript module, and Node.js uses .mjs as one way to select the ESM loader behavior. On the web and in tooling, it is commonly associated with JavaScript media types such as text/javascript.
Background
The .mjs extension is widely used in modern JavaScript development to distinguish ECMAScript modules from older CommonJS-style JavaScript. This matters because module syntax (for example, import/export) and module loading rules differ from traditional scripts.
In Node.js, .mjs is a clear signal that a file should be interpreted as an ES module even when it lives in a CommonJS-oriented context. This helps avoid ambiguity in mixed codebases and makes module behavior more predictable.
On desktops, .mjs is typically just plain text source code, so many text editors can open it. However, “opening” may mean different things: viewing/editing the code in an editor, or executing it with a runtime (which can run code and access your system depending on what the script does).
Common MIME types: text/javascript
Further reading
Authoritative resources for more details on the .MJS format.
Common .MJS issues
The file opens as plain text or “unknown file type”
Many systems don’t assign a default app for .mjs even though it’s just JavaScript source code.
- Open it with a code editor or any plain-text editor using “Open with”.
- If you work with .mjs frequently, set your preferred editor as the default app for this extension.
Node.js errors about modules (import/export not working)
Module behavior depends on how Node.js decides whether a file is an ES module; .mjs is one explicit signal to use the ES module loader.
- Confirm the file name ends with .mjs and run it as: node yourfile.mjs.
- If you copied code from a .js project, make sure it uses ES module syntax and that you are running it in a context that supports ESM.
Web/server MIME type problems when hosting .mjs
If a server sends the wrong JavaScript media type, browsers and tools may refuse to load it as expected.
- Configure your server to send a JavaScript media type such as text/javascript for .mjs responses.
- Verify the Content-Type header in your browser’s developer tools or network inspector.
FAQ
Is .mjs a “document” file?
Most commonly, no—.mjs is a JavaScript ECMAScript module source file. It’s typically plain text code meant to be edited in a code editor or executed by a runtime like Node.js.
Can I rename .mjs to .js (or vice versa)?
Renaming may change how tools interpret the file (module vs. non-module behavior), and can break imports/exports or runtime expectations. Prefer keeping .mjs when you specifically need ES module interpretation.
What MIME type should .mjs use?
JavaScript media types such as text/javascript are commonly used; the IANA registry and RFC 9239 cover ECMAScript/JavaScript media types and related guidance.
How do I run an .mjs file?
On desktops with Node.js installed, you can run it from a terminal/command line using: node yourfile.mjs.
Similar file extensions
Compare related formats in the same category to find the right tool faster.