Free online tool

Free Online HTML, CSS and JavaScript Playground

Write HTML, CSS and JavaScript and see the result live in a locked-down frame with a console, examples and download. No sign-up and no uploads.

HTML, CSS and JavaScript PlaygroundFree online tool. Runs in your browser.
Live

The fastest way to learn web code is to change something and watch what happens. This playground gives you three editors for HTML, CSS and JavaScript and a live preview underneath or beside them. It also takes security seriously: your code runs in a sealed frame that cannot reach this website, your cookies or your stored data, and cannot send anything over the internet. You can experiment freely, even with code you found online.

What is on the page

There are three boxes. The HTML box holds the body of the page, the CSS box holds its styles and the JavaScript box holds its behaviour. Press Run, or use Ctrl+Enter, and the preview rebuilds from scratch. Anything you pass to console.log, plus errors and warnings, appears in a console below the preview. You can switch the preview to tablet or phone width, put the editors beside the preview on a wide screen, turn on automatic running while you type, and start from a ready-made example.

Control What it does
Run Rebuilds the preview from your three boxes
Examples Loads a starter such as a counter, cards or a to-do list
Preview width Tests full, tablet and phone widths
Download as .html Saves your work as one standalone page
Copy all code Puts the complete page on your clipboard

A first session

  1. Choose the Click counter example and press Run.
  2. Change the colour in the CSS box and run again.
  3. In the JavaScript box, make the button add 5 instead of 1.
  4. Add a console.log line and see the message in the console.
  5. Download the page and open it in your browser to see it outside the playground.

How the sandbox protects you

Your code is placed in an iframe with the sandbox attribute set to allow scripts and nothing else. That gives it an empty identity, so it cannot read the cookies or storage of the site around it, cannot reach into this page, and cannot navigate the whole tab away. It cannot open pop-ups or submit forms. In addition, a strict content security policy inside the frame blocks every network request: no fetch, no images, scripts or fonts from other sites. We tested these limits with code that tries to read the parent page, use local storage, load an external script, fetch an address and change the top location, and each attempt was refused.

What this means for libraries

Because outside requests are blocked, you cannot load a library from a CDN with a script tag. Plain HTML, CSS and JavaScript work, as do images written as data addresses. This is a deliberate trade for safety. If you need a library, paste its source into the JavaScript box, or build and test on your own computer.

Runaway loops

A badly written loop can freeze a browser tab. The playground adds a counter to for and while loops that use curly brackets and stops them with an error after two million repeats, which is plenty for learning but not for endless loops. Loops without brackets, do-while loops and recursion are not guarded, so if the tab hangs, close it. Your code is saved in your browser every time you run, so you can usually get it back when you return.

Ideas to practise

  • Recreate a button style you like, using hover and focus rules.
  • Build a grid of cards that rearranges itself on a phone.
  • Make a list where clicking an item crosses it out.
  • Write a function that converts temperatures and logs the results.
  • Break something on purpose and read the error in the console.

Limits

This is a learning tool, not a full development environment. It has no multiple files, no modules and no syntax colouring. Dialogs such as alert are blocked because they would interrupt the frame, so use the console instead. Forms cannot submit anywhere, so handle the submit event in JavaScript. Local storage is unavailable inside the frame. For anything you plan to publish, test in several browsers.

When your page needs data in a table, use the HTML table generator, and for patterns in text, the regex tester. The guide to HTML, CSS and JavaScript introduces the three languages, and the courses on HTML, CSS and JavaScript take you step by step.

Good habits for learning

Change one thing at a time and run again, so that you know which edit caused which effect. Read errors in the console from the top: the first message is usually the real cause and later ones follow from it. Keep small working versions by downloading the page before a big change. When something works, try to explain in your own words why, because explaining is what turns copied code into understanding.

Key takeaways

  • Edit HTML, CSS and JavaScript and see the result straight away.
  • Code runs in a sealed frame that cannot reach this site, your cookies or the network.
  • Libraries from the internet cannot load, by design.
  • Loops with brackets are stopped after two million repeats.
  • Download your page as a single HTML file whenever you like.

Questions

Is it safe to run code I found online here?

It is much safer than running it on a normal page. The code is placed in a sandboxed frame with no access to this website, your cookies or stored data, and a strict policy blocks all network requests. It cannot open pop-ups or submit forms. Even so, never paste secrets into any code you did not write.

Why can I not load jQuery or another library?

All requests to other sites are blocked on purpose, so scripts, styles, fonts and images from the internet will not load. That stops code from sending your data out or pulling in unknown scripts. Paste the library source into the JavaScript box, or use data addresses for images.

Why does my page not use alert or prompt?

Dialogs are blocked inside the sandbox because they would interrupt the frame. Use console.log to show values and read them in the console panel under the preview. For input, build a text box and a button in the HTML and handle them with JavaScript.

Will my code be saved?

Your three boxes are saved in your browser each time you run, so they are there when you come back on the same device. Nothing is sent to a server. Download the page or copy the code if you want a copy elsewhere, and note that clearing browser data removes the saved version.

What happens if my code has an infinite loop?

Loops with curly brackets are stopped after two million repeats, and the console shows an error. Loops without brackets, do-while loops and endless recursion are not guarded and can freeze the tab. If that happens, close the tab. Your most recent run is usually still saved when you reopen the page.