JavaScript File — JavaScript source file for web and Node.js applications.
Quick facts
What is .js
A .js file is a JavaScript File — JavaScript source file for web and Node.js applications.
In the mime-db registry it maps to text/javascript with UTF-8 encoding, and it is marked as compressible. When serving .js over HTTP, set the Content-Type header as shown in Developer info below.
Related entities: it maps to text/javascript and is used by JavaScript among others — and is delivered over HTTP via the Content-Type header.
How to open .js files
Developer info
When served over HTTP, responses should set the following header:
Content-Type: text/javascript; charset=utf-8
Common software that reads/writes .js:
Relation chain
Related extensions
Related MIME types
Related programming languages
Common uses
How to edit .js files
How to create .js files
Example
function greet(name) {
return `Hello, ${name}!`;
}
greet('World');Frequently asked questions
Common options include VS Code, Node.js, Chrome DevTools. You can also open many of these files with built-in viewers or a browser.
Create a new file in any text editor or the app that owns the format and save it with the .js extension.
text/javascript is the media type identifier used for .js files during network transfer (for example in the HTTP Content-Type header).
Sources & standards
Updated 2026-08-18
Explore this reference