JS (.js)
.js file signature | text/javascript
High Risk Format
This file type can contain executable code. Always validate the source and scan with antivirus before opening.
Magic Bytes
Offset 0
2F 2A 20 6A 51 75 65 72 79 20
Sources: Apache Tika
All Known Signatures
10 signature variants are documented for .js files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 2F 2A 20 6A 51 75 65 72 79 20 | 0 | Apache Tika |
| 2F 2A 21 20 6A 51 75 65 72 79 20 | 0 | Apache Tika |
| 2F 2A 21 | 0 | Apache Tika |
| 28 66 75 6E 63 74 69 6F 6E 28 65 2C 75 6E 64 65 66 69 6E 65 64 29 7B | 0 | Apache Tika |
| 21 66 75 6E 63 74 69 6F 6E 28 77 69 6E 64 6F 77 2C 75 6E 64 65 66 69 6E 65 64 29 7B | 0 | Apache Tika |
| 2F 2A 20 20 50 72 6F 74 6F 74 79 70 65 20 4A 61 76 61 53 63 72 69 70 74 20 | 0 | Apache Tika |
| 76 61 72 20 50 72 6F 74 6F 74 79 70 65 3D 7B | 0 | Apache Tika |
| 66 75 6E 63 74 69 6F 6E 20 24 77 28 74 29 7B | 0 | Apache Tika |
| 2F 2A 2A 20 40 6C 69 63 65 6E 73 65 20 52 65 61 63 74 | 0 | Apache Tika |
| 2F 2A 2A | 0 | Apache Tika |
Extension
.js
MIME Type
text/javascript
Byte Offset
0
Risk Level
High
Validation Code
How to validate .js files in Python
def is_js(file_path: str) -> bool:
"""Check if file is a valid JS 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 .js files in Node.js
function isJS(buffer: Buffer): boolean {
const signature = Buffer.from([0x2F, 0x2A, 0x20, 0x6A, 0x51, 0x75, 0x65, 0x72, 0x79, 0x20]);
return buffer.subarray(0, 10).equals(signature);
}
How to validate .js files in Go
func IsJS(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
/api/v1/js
curl https://filesignature.org/api/v1/js
See the full API documentation for all endpoints and parameters.
Frequently Asked Questions
What is a .js file?
A .js file is a JS file.
What are the magic bytes for .js files?
The magic bytes for JS files are 2F 2A 20 6A 51 75 65 72 79 20 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .js file?
To validate a .js file, read the first bytes of the file and compare them against the known magic bytes (2F 2A 20 6A 51 75 65 72 79 20) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .js files?
The primary MIME type for .js files is text/javascript.
Is it safe to open .js files?
JS (.js) files are high risk because they can contain executable code. Never open .js files from untrusted sources. Always scan with antivirus software, verify the source, and consider running in a sandboxed environment.