JavaScript Playground Online

Write JavaScript in your browser and see the result as you type: the code runs about half a second after you stop typing, and you get the value it returns plus every line it writes with console.log. Share a snippet with a link, or sign in to keep a history of your code.

How to use

  1. Type or paste your code into the editor. It runs as the body of a function, so use return to show a result, such as a number, as the Output.
  2. Wait a moment or click Run; Output shows the returned value and Console Logs lists each console.log call.
  3. Use Copy Output or Copy Code to copy, Clear Output to hide the result, or Clear to empty the editor.
  4. Click Share to copy a link to the code and its output. When you are signed in with Google or LinkedIn, Save stores the snippet, and History & Shares lists your saved code and shared links.

Example

Input

let sum = 0;
let count = 10000;

for (let i = 1; i <= count; i++) {
  sum += i;
}

console.log("Multiply:", sum*count);

return sum/count;

Output

Output: 5000.5

Console Logs:
Multiply: 500050000000

Frequently asked questions

Why does Output say undefined?

Only the value after return is shown as Output. Code without a return statement, or with a bare return, shows undefined; the console.log lines still appear under Console Logs.

How do I inspect an object or array?

console.log joins its arguments with spaces as plain text, so an object prints as [object Object]. Wrap the value in JSON.stringify, for example console.log(JSON.stringify(user, null, 2)), to see its contents. Only console.log is captured; other console methods such as console.error are not available in the playground.

Where does my code run?

In your own browser tab, with the page's JavaScript engine; it is not sent to a server to be executed. It is not isolated from the page, so an endless loop freezes the tab until you reload it. Only Share and Save send the code and its output to Quto, to store them.

Does a shared link run the code?

No. A shared link opens the stored code with its saved output and marks it as a Shared View. The code runs again as soon as you edit it or click Run.

Related tools