JavaScript Tester

Run JavaScript, see the console, and test it with expect().

CONSOLE
Console output appears here.

JavaScript Tester – Run and Test JS in the Browser

The JavaScript Tester runs your code in an isolated sandbox and shows everything it prints: console.log, info, warn, error, table, count, time/timeEnd and assert. Uncaught exceptions and rejected promises are reported with their line number, and syntax errors are caught before the code runs, with a code frame that points at the exact column.

Built-in unit tests

The tester also includes a tiny test runner with a Jest-like API, so you can check a function without installing anything:

  • test(name, fn) / it(name, fn) and describe(name, fn) to group tests.
  • expect(value) with toBe, toEqual (deep), toBeTruthy, toBeFalsy, toBeNull, toBeUndefined, toBeGreaterThan, toBeLessThan, toBeCloseTo, toContain, toHaveLength, toMatch, toThrow and .not.
  • assert(condition), assert.equal, assert.strictEqual and assert.deepEqual in Node style.

Async tests work as well: return a promise or use an async function. Each test shows a pass or fail mark with its run time, and a failing assertion explains what was expected.

Safe by design

Code runs in an iframe with the sandbox="allow-scripts" attribute and no same-origin access. It cannot read this page, its cookies or local storage, and every message it sends back is tagged with a one-time token. Runs that take longer than five seconds are stopped and reported.

Script or module

Switch on ES module to use top-level await and import from URLs (for example an ESM CDN). In module mode the code is in strict mode and variables are not global.

Typical uses

Try out an algorithm while studying, check a regular expression, verify a utility function before pasting it into a project, or reproduce a bug in a few lines to share with a colleague. Need a visible page with HTML and CSS? Use the JavaScript Playground.

Frequently Asked Questions

No. It runs in a sandboxed iframe without allow-same-origin, which gives it a unique opaque origin. It cannot read cookies, local storage or the DOM of this page; it can only post messages that the tester displays.

The tester stops waiting after five seconds, removes the sandbox and shows that the run was stopped. A tight synchronous loop may still make the tab slow for a moment until the frame is removed.

Turn on ES module mode and import from an ESM CDN, for example import confetti from 'https://esm.sh/canvas-confetti'. Bare package names such as 'lodash' cannot be resolved without a bundler.

It covers the most used matchers with the same names and behavior, but it is a lightweight runner: there are no mocks, snapshots or beforeEach hooks.