# Node.js and the browser
Both environments execute JavaScript, but the host decides which APIs are available. V8 is the JavaScript engine used by Google Chrome/Chromium and Node.js: it parses and executes JavaScript and optimizes frequently used code. Chrome provides DOM and browser APIs on top of V8; Node provides fs, process, streams, and event-loop/I/O integration on top of V8 and libuv. V8 itself provides neither document nor filesystem access.
| Question | Browser | Node.js |
|---|---|---|
| What does the code interact with? | Pages, DOM, user input, Web APIs | Files, processes, servers, CLI, Node APIs |
Can it use document/window? | Yes, in a page | No, not by default |
Can it use node:fs? | Not as a normal browser API | Yes, subject to OS permissions |
| What module styles are typical? | ES modules (import) | CommonJS (require) and ES modules (import) |
| Who chooses the runtime version? | The user's browser | The application/deployment owner |
// Browser: document.querySelector('button')
// Node.js: process.argv[2], require('node:fs')
The browser isolates websites with origin-based protections and does not give arbitrary scripts full filesystem access. Node runs with the permissions of its process: never execute untrusted code or install packages blindly. Some APIs overlap (for example modern Node also includes fetch); the distinction is the runtime's capabilities, not two different JavaScript languages.
Firefox uses SpiderMonkey and Safari uses JavaScriptCore; sharing the ECMAScript language does not require sharing V8. Browser and Node scheduling also differ: Node's libuv phases and process.nextTick() are not browser APIs; see the event loop.
Node vs browser (opens new window) · The V8 JavaScript engine (opens new window)