JavaScript Playground

Write JavaScript, press Run, and read the output in the console beside it. Objects, arrays, Maps and Sets print in a readable form, and errors show their message and line number. The code runs in a sandbox inside your browser with no access to this site or the network, so it is a safe place to try out logic, array methods or a snippet you found online.

Ctrl + Enter in an editor
Console

Press Run to start.

Page

Your code runs in a locked-down frame in your browser: it cannot read this site, your cookies or other tabs, and it has no network access, so fetch() and external files are blocked. Nothing is uploaded or saved; download the .html to keep your work.

Features

  • Console that prints console.log, info, warn, error and console.table data

  • Readable output for objects, arrays, Maps, Sets, Dates and errors

  • Uncaught errors and rejected promises reported with their message

  • Run with the button or Ctrl + Enter; optional run-as-you-type

  • A small page frame for code that touches document.body

  • No network access and no access to this site, by design

What to run here

Practising for interviews

Write and test solutions to array, string and recursion problems and check the output with console.log, without opening an IDE.

Checking how a method behaves

Try what Array.prototype.sort does with numbers, how toLocaleString formats rupees, or how Date parses a string, in a few lines.

Trying a snippet before using it

Paste code from a blog or an AI answer and see what it prints. The sandbox stops it from reading your data or calling any server.

What runs and what does not

Supported

  • Everything your browser's JavaScript engine supports: let and const, arrow functions, classes, destructuring, async/await, optional chaining, BigInt and more.
  • Timers such as setTimeout and setInterval, and promises; their output arrives in the console when they run.
  • DOM code: document.body and document.createElement work, and the result shows in the Page frame.

Not available

  • Network calls: fetch(), XMLHttpRequest and WebSocket are blocked by the sandbox's security policy.
  • import and export, npm packages and require(): the code runs as a classic script, not a module or Node.js.
  • alert(), confirm() and prompt() do not open dialogs; their text is printed in the console, confirm() returns false and prompt() returns null.
  • localStorage, cookies and anything else tied to a site, because the sandbox has no origin of its own.

Endless loops

Code that never finishes, such as while (true) {}, can freeze the tab. That is why this page waits for you to press Run instead of running as you type. Reload the page if it stops responding.

JavaScript Playground - FAQ