file in abyss
Back to formats

Code

JS JavaScript

JavaScript is a code format commonly identified by .js, .mjs, .cjs. Use the listed signatures, MIME types, and structure notes to validate files beyond the extension.

Extensions .js, .mjs, .cjs
MIME text/javascript, application/javascript

Magic numbers

Analyze your file
offset 0 JavaScript leading signature
65 78 70 6F 72 74
export

Structure

  1. Statements
  2. Declarations
  3. Expressions
  4. Modules

Caveats

  • Do not trust the extension alone. Check the MIME type, the first bytes such as 65 78 70 6F 72 74, and format-specific structure when possible.
  • Container formats and damaged files can share the same opening bytes, so deeper validation may be required for production upload, preview, or conversion flows.

Detection example

SIGNATURE = bytes.fromhex("6578706f7274")
OFFSET = 0

def is_js(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

Practical usage

Use cases

JavaScript is used for data exchange, imports, exports, parser testing, and validation workflows. Encoding, delimiters, versions, and container structure often change implementation behavior.

Common detection mistakes

  • The .js / .mjs / .cjs extension alone does not prove the file contents. Upload and conversion flows should combine extension, MIME type, leading bytes, and format-specific structure checks.
  • JavaScript can start with signatures such as 65 78 70 6F 72 74, but related containers and damaged files may require additional validation.

Security notes

Untrusted input is not safe just because the format was detected. Account for parser exceptions, large files, unexpected encodings, and external references.

Using samples

11 samples help test leading-byte detection, parser errors, upload limits, and download behavior.

Sample files

11 / 11 files
Sample Traits Size Source / license / SHA-256
Code

Blue Sky JS

Blue Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.js
Type Sample
Small file
289 B
SHA-256 7d3b2994ee0a1c9c28837d0ba8de3ec918b7820baa1291e49ef20c85c9a343ff
Download
Code

Flower Garden JS

Flower Garden JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.js
Type Sample
Small file
314 B
SHA-256 e4e0e31904121880833d098f0ece7e5f03c7a87c9e8bfc347620f2b0edd23755
Download
Code

Navy Blue Sky JS

Navy Blue Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.js
Type Sample
Small file
306 B
SHA-256 68a18b0a81d6a381122fdca7a48615cccef3e9321b56eb3d848906446faef1a8
Download
Code

Nature of the Sky JS

Nature of the Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.js
Type Sample
Small file
298 B
SHA-256 88f8a8495116ba8f94009b85973fe8d1682fbd9df9858f078a8a16bb8cf419c6
Download
Code

Sky Landscape JS

Sky Landscape JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.js
Type Sample
Small file
315 B
SHA-256 12c8c7523d5e78f0eef8f10c99b51f90230c44c290ae8f54d560f64222c70772
Download
Code

Starry Sky JS

Starry Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.js
Type Sample
Small file
298 B
SHA-256 d0a79f3af31aac614a4aa57699d5916597a604ad7f46e9e46d6d70f52ba5cc78
Download
Code

Blue Night Sky JS

Blue Night Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.js
Type Sample
Small file
292 B
SHA-256 d172ade12c1b20dc0894883054a56a48036c23d954ae2d33c29e75323ed99492
Download
Code

Hibiscus Flower JS

Hibiscus Flower JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.js
Type Sample
Small file
319 B
SHA-256 add6427d73d92168b6c82a494d5767ab535830a8800de179191eca218c1dcd47
Download
Code

Arctic Sky JS

Arctic Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.js
Type Sample
Small file
300 B
SHA-256 faec434d8db0ad7ebc4aa173410aa473e07ff40afb5e9f79f1e7ed9e40b75c0a
Download
Code

Sunset Rays JS

Sunset Rays JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

10-sunset-rays.js
Type Sample
Small file
303 B
SHA-256 ff8d74f4347a005c4c07e4e0c1914439b5b893d81328fd483c378ad2efd7324a
Download
Code

NASA Blue Marble JS

NASA Blue Marble JS is a JavaScript sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.js
Type Sample
Small file
354 B
SHA-256 83674dbcffe0c1c778f58bac76805f2f5b1f6399e064a9ec50feba9c7624cdf2
Download

Frequently asked questions

What is the magic number (file signature) of JavaScript?

JavaScript files begin with the byte signature 65 78 70 6F 72 74 ("export"). Detect the format by reading these leading bytes rather than trusting the file extension alone.

What is the MIME type of JavaScript?

The MIME type for JavaScript is text/javascript, application/javascript.

What file extension does JavaScript use?

JavaScript files use the .js, .mjs, .cjs extension. The extension is a convention only and does not guarantee the file contents, so combine it with signature and structure checks.