JavaScript Sandbox
Write HTML, CSS, and JavaScript and see live results instantly — like a mini CodePen in your browser
Write HTML, CSS, and JavaScript in three separate tabs, hit Run (or just keep typing — auto-run fires after 300ms), and watch the live preview update instantly with a built-in console panel for quick debugging. Download the result as a single .html file when you’re done. And everything runs in your browser. Nothing gets uploaded.
How It Works
Your code from all three tabs gets combined into a single HTML document and injected into a sandboxed iframe using srcdoc. The iframe runs it like a normal web page. A small script wrapper intercepts console.log, console.warn, and console.error calls, then passes them back to the parent page so they show up in the console panel. Auto-run triggers 300ms after you stop typing.
Examples
Quick DOM manipulation test
You want to check if a classList toggle works the way you think it does.
const box = document.getElementById('box');
box.addEventListener('click', () => {
box.classList.toggle('active');
console.log('Active:', box.classList.contains('active'));
});
> Active: true
> Active: false
> Active: true
CSS animation prototyping
Testing a bounce-in keyframe animation before dropping it into a real project. Write the HTML in one tab, the CSS in another, and instantly see the result.
@keyframes bounceIn {
0% { transform: scale(0.3); opacity: 0; }
50% { transform: scale(1.05); }
100% { transform: scale(1); opacity: 1; }
}
.card { animation: bounceIn 0.6s ease-out; }
A card element that bounces into view with a smooth scale + fade animation. Tweak the percentages and see changes instantly.
Fetch API response debugging
Checking what an API actually returns before building the UI around it.
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(r => r.json())
.then(data => {
console.log('Title:', data.title);
console.log('Body length:', data.body.length);
});
> Title: sunt aut facere repellat provident occaecati excepturi optio reprehenderit
> Body length: 292
Who Uses This
Testing a CSS trick or debugging a DOM issue without spinning up a whole dev server.
Working through homework exercises or following along with a JavaScript tutorial in real time.
Verifying code snippets actually work before putting them in documentation or blog posts.
Prototyping a hover effect or animation without asking a developer to set up a branch.
Common Mistakes
Your JavaScript runs twice — once from the script tag, once from the JS pane injection. Move all JS code to the JS tab and keep HTML for markup only.
The JS pane code runs at the end of the body, so elements from the HTML pane should already exist. But if you’re dynamically creating elements in JS and then immediately querying them, add a short setTimeout or use event listeners.
A while(true) or runaway recursion will lock up the iframe. The sandbox can’t stop it once it starts. If the preview goes blank or unresponsive, hit “Clear All” and fix your loop condition before running again.
Technical Details
- Processing: 100% client-side — code never leaves your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Preview Method: Sandboxed iframe with
srcdocinjection - Auto-run Delay: 300ms debounce after last keystroke
- Export Format: Single self-contained .html file
Frequently Asked Questions
Can I use React, Vue, or other frameworks in this sandbox?
Yes, but you’ll need to load them via CDN. Add a script tag like <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script> in your HTML pane. JSX won’t work without a transpiler though — you’d need to include Babel standalone too, which gets heavy. For quick experiments it is fine, but for anything serious a dedicated React playground would be better.
Is my code saved if I close the tab?
No. This sandbox doesn’t use localStorage or any persistence. Close the tab and your code is gone. If you want to keep your work, click “Download HTML” before leaving. That gives you a standalone file you can reopen in any browser.
Why does my console.log not show up?
The console capture only works for code running inside the preview iframe. If your script throws an error before reaching the console.log call, it won’t appear. Check for syntax errors first. Also, console.log inside a setTimeout or async function will show up — but only after that code actually executes.
How is this different from CodePen or JSFiddle?
Those are full platforms with accounts, sharing, and community features. This is a single-page tool that runs entirely in your browser. No signup, no server, no tracking. It’s faster to open and use when you just need to test something quick. The tradeoff is you don’t get saved projects or collaboration.
Can I access APIs and fetch external data?
Absolutely. The preview iframe has normal network access, so fetch() and XMLHttpRequest work as expected. The only catch is CORS — if the API you’re calling doesn’t allow cross-origin requests from a null origin, it’ll fail. Most public APIs like JSONPlaceholder or OpenWeather work fine.