Write code and run it in a sandboxed frame with no network.
Runs in this browser. Nothing is uploaded.
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.
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.
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.
The allowlist is the behavior. Pasted markup cannot grow a script or an iframe just because the preview is willing to render a heading.
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.
class, id, title, style, lang, dir, value and placeholder, on a fixed set of ordinary elements. href and src are not in that set.
Not from a URL. The frame blocks the network. The preview is the markup and CSS you typed.
The squares of 1, 2 and 3, so the console shows 1, 4, 9. That sample is the JavaScript playground’s starting point, not this page’s.