A lightweight, browser-based code editor for HTML, CSS, and JavaScript with live preview and instant testing capabilities. Perfect for teaching, learning, and rapid prototyping without any setup required.
- Triple Editor Setup: Dedicated editors for HTML, CSS, and JavaScript
- Live Preview: See your code changes instantly in a sandboxed iframe
- Test Integration: Add validation tests that run alongside student code
- Save & Load: Export/import projects as JSON files
- Local Storage: Automatic backup of your work
- Keyboard Shortcuts:
Ctrl/Cmd + S- Save projectCtrl/Cmd + Enter- Run code
- Responsive Design: Works on desktop and tablet devices
- Dark Theme: Easy on the eyes with a modern dark interface
- Sandboxed Execution: Safe code execution in an isolated environment
-
Clone the repository
git clone https://github.com/sammi-turner/Live-Code-Editor
-
Open in Browser Simply open
index.htmlin your web browser. No server setup required! -
Start Coding
- Write HTML in the HTML tab
- Add styles in the CSS tab
- Add functionality in the JavaScript tab
- Click "Run" or press
Ctrl+Enterto see live preview
- Open the editor in your browser
- Write your code in the respective tabs
- Click "Run" to see instant results
- Your work is automatically saved locally
- Write assignment instructions in the "Task" textarea
- Add validation tests in the "Validation tests" area (JavaScript only)
- Students can run tests with the "Run with tests" button
- Share project files as JSON for standardized assignments
- Save: Downloads current project as
academy-web.json - Load: Upload previously saved JSON files
- Preview: Opens preview in a new window for full-screen testing
- Vanilla JavaScript: No frameworks, maximum compatibility
- CSS Grid & Flexbox: Modern, responsive layout
- Local Storage API: Client-side persistence
- Blob API: File download functionality
live-code-editor/
├── index.html # Main application
├── script.js # Core functionality
├── style.css # Styling and themes
└── README.md # Documentation
- Coding Bootcamps: Perfect for web development exercises
- Online Courses: Embed in LMS systems for interactive assignments
- Interview Practice: Quick prototyping without environment setup
- Teaching Kids: Simple interface for introducing web development
- Rapid Prototyping: Test ideas quickly without build tools
Modify the setDefaultContent() function in script.js to change the starter code:
function setDefaultContent(){
ed_html.setValue(`<!-- Your custom HTML -->`, -1);
ed_css.setValue(`/* Your custom CSS */`, -1);
ed_js.setValue(`// Your custom JavaScript`, -1);
}Edit CSS custom properties in style.css:
:root{
--bg: #0f1221; /* Background color */
--brand: #7dd3fc; /* Primary accent */
--ok: #22c55e; /* Success color */
--warn: #eab308; /* Warning color */
--err: #ef4444; /* Error color */
}The editor includes a built-in testing system:
- Write validation JavaScript in the "Validation tests" textarea
- Tests run after student code in the same scope
- Use
console.log()for test feedback - Students click "Run with tests" to execute
Example test:
// Check if button exists
const button = document.getElementById('myButton');
if (!button) {
console.error('Button with id "myButton" not found');
}
// Check if click handler works
let clicked = false;
button.addEventListener('click', () => clicked = true);
button.click();
if (!clicked) {
console.error('Button click handler not working');
}