FormatterHQ

JavaScript Tester (Online JS Console)

Write or paste JavaScript, press Run and see the console output: logs, warnings, errors with messages, tables and timings, all in an isolated sandbox.

Input JAVASCRIPT
Output TEXT
Ready.

How to use the JavaScript Tester

  1. Type or paste JavaScript into the editor, or open a .js file.
  2. Enable module mode if your code uses import/export or top-level await.
  3. Press Run (or Ctrl/Cmd + Enter) to execute the code in a sandbox.
  4. Read the console output below; edit and run again as often as you like.

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, warn and error, each styled differently.
  • console.table for arrays of objects, console.group for nested output, console.dir, console.count, console.assert, console.time and console.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, indexedDB and cookies are unavailable and throw errors.
  • Network requests with fetch work 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(), fs and process do not exist. Browser APIs such as document, setTimeout, crypto and Intl are 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.

Frequently asked questions

Is it safe to run JavaScript here?
Your code runs in a sandboxed iframe with its own origin, so it cannot access this site, your cookies or other tabs. As with any code, only run snippets you understand, especially ones copied from strangers.
Why does localStorage throw an error?
The sandbox has an opaque origin without persistent storage, so localStorage, sessionStorage, indexedDB and cookies are blocked. Test storage code on a local web server instead.
Can I use import statements or top-level await?
Yes, enable module mode. Imports must use full URLs, for example from an ES module CDN, because there is no local file system.
Can I run Node.js code?
No. The code runs in a browser, so Node-specific APIs such as require, fs and process are unavailable. Plain JavaScript and browser APIs work.
Why does my fetch request fail?
Requests from the sandbox are cross-origin, so the server must allow them with CORS headers. Many public APIs do; private APIs often do not.

Last updated September 26, 2026

Related tools

API Tester (REST Client) Send GET, POST, PUT, PATCH and DELETE requests to REST APIs from your browser and inspect status, headers and pretty-printed JSON. JSONPath Tester Test JSONPath expressions online against your JSON. Supports filters, wildcards, recursive descent and slices, returning values or paths. Regex Tester Test JavaScript regular expressions live: highlight matches, inspect capture groups and named groups, try flags and preview replacements. Responsive Website Tester Preview any website on phone, tablet, laptop and desktop screen sizes side by side to check your responsive design. XPath Tester Test XPath expressions online against your XML. See matched nodes, attributes, strings, numbers or booleans instantly. cURL to JavaScript Fetch Convert curl commands into JavaScript fetch() code with method, headers, JSON body, form data, basic auth and timeouts. JavaScript Key Code Finder Press any key to see its event.key, event.code, legacy keyCode, location and modifier state for JavaScript keyboard handlers. JavaScript Minifier Minify JavaScript online with Terser to shrink file size for faster websites. React JSX Formatter Format React components and JSX online with Prettier. TypeScript Formatter Format TypeScript code online with Prettier, including interfaces, generics, decorators and type annotations. Babel Formatter Format modern JavaScript and JSX using the Babel parser and Prettier. Flow Formatter Format JavaScript with Flow type annotations online using the Flow parser.