JavaScript Runner

Web

Run JavaScript in your browser with console output capture. It runs via new Function in the page runtime and keeps a history so you can rerun experiments.

Code
Output
Click "Run" to see output...

About JavaScript Runner

Need a quick way to verify a JavaScript snippet without booting up an IDE or a Node project? This tool executes JavaScript directly in the browser, captures console.log/warn/error/info output, and reports execution time in milliseconds. It supports all modern ES6+ syntax — arrow functions, async/await, optional chaining, nullish coalescing, destructuring, and template literals — so you can test real snippets as you write them. Because it runs in a browser sandbox rather than Node.js, Node built-ins like require, fs, or process are unavailable, but the full set of browser Web APIs is at your disposal. You can define variables and functions in one step and reference them later, making it handy for incrementally debugging complex logic and verifying an array or string algorithm. Pasted code executes locally with nothing uploaded, ideal for learning, quick experiments, and sharing runnable examples in docs or forum answers. Two cautions: avoid running untrusted code, and avoid mutating the page's global state. Running a short script in the browser is an efficient way to check how an expression behaves, verify a data transformation, or quickly inspect the shape of an API response: no new file, no runtime to configure, and the result appears immediately. It suits one-off verification and nothing that needs to persist. Execution uses the browser's own script engine to evaluate the code in a controlled context, so the script runs in the same runtime as the page. That is worth understanding because it decides both capability and risk: the script can reach browser interfaces including timers and network calls, which means it can issue requests and read or write page storage, so pasting an untrusted script into a third-party page hands over the page's full privileges. Practical notes: Keep frequently used fragments as templates, such as formatting an object for output, counting and de-duplicating array entries, or turning a response into a table for pasting. When debugging, prefer an explicit output statement over relying on the implicit value of the last line, which diverges from expectation once there are several statements. Await asynchronous work explicitly, or you get the illusion of a result before it has returned, the most common trap when inspecting API responses. Limits: The browser and server environments differ substantially, and something that runs in a page need not run on a server, since module loading, global objects and available interfaces all differ, so code verified here usually fails when moved into a build pipeline unchanged. A long synchronous loop also freezes the page, so process large data in chunks or on the command line. Finally, results live only in the current page and vanish on refresh, so anything worth keeping should be copied or exported deliberately. Data and privacy: this tool executes script text and does not upload the input, but a script that issues network requests will carry origin information with them. When testing an authenticated API, confirm the destination is trustworthy first, and never hardcode production credentials inside the script. The classic misuse is moving code verified here straight into a build pipeline: module loading, globals and available interfaces all differ between browser and server, so a snippet that runs locally often fails under Node. Another is running a long synchronous loop, which freezes the page until it finishes; process large data in chunks or on the command line. Results live only in the page and vanish on refresh.

How It Works Internally

Execution uses the browser script engine to evaluate code in a controlled context, so the script runs in the same runtime as the page: it can reach timers and network interfaces, which means it can issue requests and read or write page storage. That explains both the capability and the risk — pasting an untrusted script hands over the page full privileges.

Inputconsole.log([1,2,2].filter((v,i,a)=>a.indexOf(v)===i))
Output[1, 2] (in-place dedupe, same result as any JS runtime)

Measured on This Page

Output captureconsole.log('hi', 1+1) yields hi 2; objects and arrays print as indented JSON, not [object Object]
Error captureconsole.error('bad') gives ❌ bad and throw new Error('boom') gives ❌ boom without breaking the page
Fixed: asyncA console.log 50ms inside setTimeout used to be lost entirely (panel stayed at no-output)
Bare expressionTyping 1+1 prints nothing — the tool captures console output only, not expression values
MechanismIt runs code via new Function in the page runtime and is not iframe-isolated; the meta description claiming isolation has been corrected
Blank linesA blank line between two console.log calls does not affect the output

The script runs in the page's own runtime and can read and write document and localStorage, and make network requests — so 'do not run untrusted code' is not boilerplate: pasting a script hands over the page's privileges. Asynchronous output now has a 500ms capture window, and anything later is still lost, so await real async work explicitly. Bare expressions print nothing, so wrap debugging values in console.log rather than relying on the last line being shown.

How this was measured: Eight snippets were injected and run, reading the output panel: basic output, object and array printing, console.error, a thrown exception, a setTimeout log, a bare expression, and multi-line code with a blank line; the execution mechanism was also checked (new Function versus iframe isolation). · Measured 2026-10-30

How to Use

  1. Open "JavaScript Runner"
  2. Write or paste your script in the left code pane
  3. Click "Run" and watch console output on the right
  4. Check the elapsed time and any async logs
  5. Use "Clear Output" or "Clear Code" to start over

Use Cases

  • Verify algorithms — Paste code snippets and see results and output immediately.
  • Learn JavaScript — Practice while learning with real-time execution feedback.
  • Debug regex — Quickly test regex match results without switching tools.
  • Verify data processing — Test JSON parsing, array operations, and data processing code.
  • Step-by-step debugging — Define variables and functions first, then reference them in later runs to validate complex logic.
  • Share runnable snippets — Provide reproducible JS examples in docs or forum answers so others can run and confirm them.

FAQ

Is it safe?

Code runs via new Function in the browser, isolating the global scope. However, do not run untrusted code.

Does it support ES6+?

Yes. The browser natively supports all modern JavaScript syntax including async/await, arrow functions, destructuring, etc.

Can I use DOM APIs?

You can access document and window objects, but modifications may affect this page. Stick to pure logic.

Does it support Node.js APIs?

No. This is a browser environment without require, fs, process, or other Node.js APIs.

Can I run async code?

Yes. Write an async function and await inside it; results are captured and shown together, with millisecond timing for verification.

Are uncaught exceptions shown?

Yes. Thrown errors are caught and printed in red with a stack trace, making it easy to locate the failing line.

How does running JS in a browser differ from Node?

The globals and capabilities differ: no require, fs or process in the browser, but window, document and localStorage instead. File access, cross-origin requests and Node APIs will fail, while pure logic (algorithms, arrays, strings) behaves identically.

Where does console.log output appear?

The runner captures console output into the results panel — no DevTools needed. Note that console.table and object expansion may render as serialised text; stringify complex objects before logging for the most stable output.