Skip to content
OddsockLocal

JavaScript playground

Run JavaScript with a console in a sandbox without network.

Runs in this browser. Nothing is uploaded.

How to use

  1. Read or edit the JavaScript. The sample maps 1, 2, 3 to their squares.
  2. Press Run preview.
  3. Read the console. Objects are JSON when they can be serialized.
  4. Switch Editor to HTML or CSS only if you also want the allowlisted document. The script still cannot see it.

What is JavaScript playground?

JavaScript playground opens on the JavaScript editor. The starting snippet is const squares = [1, 2, 3].map(n => n * n); console.log(squares); and the HTML is cleared, so the preview is the console. Run preview logs 1, 4, 9. console.log, info, warn, error, debug and table are all redirected to that console, with a cap on how many lines and how long each line can be.

Read more

The script runs in a worker, not in the frame’s document. There is no DOM. document, window and a query for the heading do not exist there. The HTML and CSS editors are still available if you switch Editor, and any markup you add is allowlisted the same way as on the HTML playground, but the script cannot read it. The worker is terminated after five seconds, so a tight loop does not hang the tab.

The CSS playground starts on a stylesheet and the specimen HTML. The HTML playground starts on that specimen with empty JavaScript. This page starts from the console. None of them can fetch, open a socket, or navigate. A syntax error is reported on the console.

Use cases

  • You want the squares of 1, 2 and 3, logged as 1, 4, 9, before you edit the array.
  • A snippet should be tried without giving it the page’s document or a network call.
  • An infinite loop should die at five seconds instead of freezing the browser tab.
  • You need to see an exception in the console without building a file.

The sample squares

const squares = [1, 2, 3].map(n => n * n); console.log(squares);

The console shows 1, 4, 9. HTML starts empty, so the frame’s document body has no specimen heading.

Why use Oddsock

No DOM is the constraint. A snippet that works here does not depend on the page that happens to be hosting the frame.

Related tools

Using this tool

The script runs in a worker. There is no document. console.log is redirected to the preview. The HTML you type is a separate frame the worker cannot touch.