Skip to content
OddsockLocal

HTML, CSS and JS playground

Write code and run it in a sandboxed frame with no network.

Runs in this browser. Nothing is uploaded.

How to use

  1. Edit HTML, or switch Editor to CSS or JavaScript.
  2. Press Run preview.
  3. Read the frame. Only allowlisted tags and attributes from the HTML are copied.
  4. If you added JavaScript, read the console under the preview. It has no DOM, and it stops after five seconds.

What is HTML, CSS and JS playground?

HTML playground starts in the HTML editor, on a heading and a paragraph: Type specimen, and Edit this paragraph or its style. The CSS editor already holds a system font, padding, and an italic h1. JavaScript starts empty. Editor switches among HTML, CSS and JavaScript. Run preview builds a frame. Close preview removes it.

Read more

The frame does not trust the markup. Tags are copied from a list of ordinary elements, and only a few attributes survive: class, id, title, style, lang, dir, value, placeholder. A script element, a link, an iframe or an onclick in the HTML is dropped. CSS is inserted as a style tag. If you type JavaScript, it runs in a separate worker with console.log and the other console methods rewritten to the preview’s console. The worker has no document, so document.querySelector will not find the heading. The worker is stopped after five seconds.

The CSS playground is this same frame opened on the CSS editor. The JavaScript playground opens on a snippet that maps 1, 2, 3 to their squares and logs 1, 4, 9, with the HTML cleared so the console is the result. None of the three loads a network resource.

Use cases

  • You want to change the specimen heading and see the italic style still apply after Run preview.
  • A pasted page includes a script tag and you want that tag omitted rather than executed.
  • You need a console without giving the script access to the heading’s DOM.
  • You are deciding between starting in HTML here, in CSS on the CSS playground, or on the squares snippet in the JavaScript playground.

The specimen, run as it stands

HTML: a heading Type specimen and a paragraph. CSS: system-ui, 1rem padding, h1 italic. JavaScript empty.

Run preview shows the italic heading and the paragraph. The console stays empty because no JavaScript was entered.

Why use Oddsock

The allowlist is the behavior. Pasted markup cannot grow a script or an iframe just because the preview is willing to render a heading.

Related tools

Using this tool

Script tags in the HTML are not copied into the frame. Put code in the JavaScript editor. It runs in a worker and cannot see the document.