What file extension is used for JavaScript files?

The story behind the answer

The standard file extension used for JavaScript files is .js.

The extension identifies a text file whose contents are intended to contain JavaScript source code. Web browsers commonly load such files with a script element, while server-side runtimes such as Node.js, Deno, and Bun can execute JavaScript files directly. The same extension is used whether the code is a small browser script or part of a large application.

JavaScript was created at Netscape in the 1990s and standardized as ECMAScript. The name of the language and its standard are different, but ordinary source files still conventionally use .js. The extension .java belongs to Java, a separate programming language, despite the similar names. Likewise, .jsx is commonly used for JavaScript files containing JSX syntax, especially in React projects, but it is a specialized convention rather than the basic JavaScript extension.

Modern JavaScript environments also recognize .mjs for ECMAScript modules and .cjs for CommonJS modules. Those extensions communicate module behavior to some runtimes; .js remains the general-purpose and most widely recognized choice.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: