Test JavaScript without opening DevTools
Sometimes you just want to check what [1, 10, 2].sort() returns, try a regular expression or debug a small function. This JavaScript tester runs your code in the browser and shows a clean console with everything it prints. It is quicker than setting up a project and friendlier than the browser's developer tools for sharing or teaching.
Example
const users = [
{ name: 'Ada', age: 36 },
{ name: 'Linus', age: 28 },
];
console.table(users);
console.log([1, 10, 2].sort()); // [1, 10, 2]: compared as strings
console.log([1, 10, 2].sort((a, b) => a - b));
console.warn('Careful: sort() compares strings by default');
await new Promise((r) => setTimeout(r, 100));
console.log('done after 100 ms');The console shows a table of users, both sorted arrays, a highlighted warning and the final message. (Run it in module mode for the top-level await.)
Supported console features
console.log,info,debug,warnanderror, each styled differently.console.tablefor arrays of objects,console.groupfor nested output,console.dir,console.count,console.assert,console.timeandconsole.clear.- Objects, arrays, Maps, Sets, functions and other values are printed in a readable, expandable form.
- Uncaught exceptions and unhandled promise rejections are shown as errors with their message, so failures never pass silently.
Script or module
By default your code runs as a classic script. Enable module mode to use import and export, top-level await and strict mode semantics. Modules can import libraries from a CDN by full URL, for example import confetti from 'https://esm.sh/canvas-confetti';.
How the sandbox works, and its limits
Your code runs inside a sandboxed iframe with its own opaque origin. That keeps it isolated from this website: it cannot read cookies, local storage or other tabs, and it cannot interfere with the page around it. The trade-offs:
localStorage,sessionStorage,indexedDBand cookies are unavailable and throw errors.- Network requests with
fetchwork only for servers that allow cross-origin requests (CORS) from any origin. - Each run starts fresh; variables do not persist between runs.
- There is no Node.js here, so
require(),fsandprocessdo not exist. Browser APIs such asdocument,setTimeout,cryptoandIntlare available. - An infinite loop blocks the sandbox; reload the page if that happens.
Reading errors
When your code throws, the console shows the error type and message, for example TypeError: Cannot read properties of undefined, instead of stopping silently. Errors raised inside async functions or rejected promises are caught too. Add console.log calls before the failing line to inspect values, then run again; the turnaround is a fraction of a second.
Handy uses
- Checking language behavior while learning: equality rules, closures,
this, promises. - Prototyping a utility function before adding it to a project.
- Testing regular expressions and date formatting with
Intl. - Reproducing a bug in a minimal snippet to share with colleagues.
Need to inspect JSON output? Paste it into the JSON formatter. To check syntax without running anything, use the JavaScript validator, and for pages with HTML and CSS try the real-time HTML editor. Your code runs only in your browser and is never sent to a server.