MJS

text/javascript

Safe

Magic Bytes

Offset: 0
2F 2A 20 6A 51 75 65 72 79 20

MJS files represent ECMAScript Modules, a JavaScript source code format standardized by ECMA International and utilized primarily within the Node.js runtime environment. These files enable strict modularity in applications, allowing developers to explicitly separate code scope using native import and export statements distinct from legacy CommonJS. While standard text-based source code is inherently safe to view, these scripts execute arbitrary logic and should be reviewed before running in privileged environments.

Extension

.mjs

MIME Type

text/javascript

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .mjs files in Python

Python
def is_mjs(file_path: str) -> bool:
    """Check if file is a valid MJS by magic bytes."""
    signature = bytes([0x2F, 0x2A, 0x20, 0x6A, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20])
    with open(file_path, "rb") as f:
        return f.read(10) == signature

How to validate .mjs files in Node.js

Node.js
function isMJS(buffer: Buffer): boolean {
  const signature = Buffer.from([0x2F, 0x2A, 0x20, 0x6A, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20]);
  return buffer.subarray(0, 10).equals(signature);
}
Go
func IsMJS(data []byte) bool {
    signature := []byte{0x2F, 0x2A, 0x20, 0x6A, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20}
    if len(data) < 10 {
        return false
    }
    return bytes.Equal(data[:10], signature)
}

API Endpoint

GET /api/v1/mjs
curl https://filesignature.org/api/v1/mjs

Related Formats