Skip to content

Code Playground

Write HTML, CSS, and JavaScript with live preview. Like a mini CodePen — entirely in your browser.

PREVIEW

Related Tools

Markdown Editor Rich Text to HTML Converter HTML Preview CSS Formatter & Minifier JSON Formatter & Validator

How to Use

  1. Write Your Code — Switch between the HTML, CSS, and JS tabs to write your code. Each tab has a dedicated editor with tab-key indentation (press Esc, then Tab, to move focus out) and monospace font. The preview updates automatically as you type (500ms debounce).
  2. See Live Preview — The preview panel shows your rendered output in a sandboxed iframe. HTML structure, CSS styling, and JavaScript interactions all work together in real-time. Open the Console to see console.log output and any errors.
  3. Export Your Work — Click Download to save your project as a single HTML file with embedded CSS and JS. Click Copy to copy all three sections to your clipboard. The exported file works standalone in any browser.

About the Code Playground

The Code Playground is a small HTML, CSS and JavaScript editor with a live preview and a console, in the spirit of CodePen or JSFiddle but without accounts or saved projects. It is for trying a layout idea, testing a snippet from a tutorial, reproducing a bug in isolation, or teaching the basics of the web. Your code runs only in your own browser.

How the preview is built

Every run combines the three tabs into one HTML document. Your CSS goes into a <style> in the head, after a small default style for the body (system font, 16px margin, dark gray text). Your HTML goes into <body>, and your JavaScript into a <script> at the end of the body, so every element already exists when your script runs. The document is loaded into the preview with srcdoc, so no server is involved. With Auto-run on, the preview rebuilds 500 ms after you stop typing. Switch it off to run only when you press Run.

The preview iframe has sandbox="allow-scripts allow-modals". In practice:

Worked example

TabCode
HTML<h1 id="t">Hi</h1>
CSSh1 { color: teal; }
JS, line 1const t = document.getElementById("t");
JS, line 2t.textContent += "!";
JS, line 3console.log(t.textContent);
JS, line 4sayHi();

The preview shows a teal heading reading "Hi!". The Console shows > Hi!, then the browser's error for the undefined function (for example sayHi is not defined) followed by (JS line 4), and it opens automatically because an error occurred. The console hook runs in its own script before yours, so it catches syntax errors as well as runtime errors, and it reports line numbers relative to your JS or HTML tab rather than the combined document.

Limitations

Practical tips

Your HTML, CSS and JavaScript are never uploaded: the preview is generated and run inside your browser.

Frequently Asked Questions

How does the live preview work?

When you type in any editor tab, the playground combines your HTML, CSS, and JavaScript into a complete HTML document and renders it in a sandboxed iframe using the srcdoc attribute. The preview updates automatically after 500ms of inactivity. You can also click the Run button for immediate execution. The iframe is isolated from the parent page for security.

Does JavaScript work in the preview?

Yes. JavaScript runs in the preview iframe: DOM manipulation, event listeners, timers, alert dialogs and most browser APIs work normally. For privacy and security, the preview cannot reach other websites: fetch() and other network requests to external servers are blocked, and external script or stylesheet files (for example libraries loaded from a CDN) do not load, so paste library code directly into the JS or CSS tab instead. Images from https URLs do display. console.log, console.error, and console.warn output is captured and displayed in the built-in Console panel below the preview.

Can I see console output and errors?

Yes. Click the Console toggle to show the console panel. Any console.log, console.warn, or console.error calls from your JavaScript are captured and displayed with color-coded output (gray for log, yellow for warn, red for error). Runtime and syntax errors are also caught and displayed with the line number in your JS or HTML tab.

Can I download my code as a file?

Yes. Click Download to save your project as a single, self-contained HTML file. The file includes your HTML in the body, CSS in a style tag, and JavaScript in a script tag, plus the same default page styles the preview uses. You can open the downloaded file in any browser and it will look and behave like the preview, except that external files and network requests blocked in the preview will load normally there.

Is this like CodePen?

It provides similar core functionality: separate HTML, CSS, and JS editors with a live preview panel. The key differences are that WritePadPro runs entirely in your browser with no account required, no server saves, and no data transmitted anywhere. Your code stays private on your device. It is designed for quick prototyping, testing snippets, and learning.

Is my code private?

Completely. All code editing and preview rendering happens in your browser. Your HTML, CSS, and JavaScript are never sent to any server, stored in any database, or processed by any API. The preview iframe uses srcdoc (not a server URL), so even the rendered output stays local.