Workonline-code-editor-react-express

Online Code Editor

I built a browser-based code editor with two tools: a web editor where HTML, CSS and JavaScript render in a live preview, and a Markdown editor with a toolbar and a download button.

Role
Frontend Developer
Timeline
May 2022 – Jun 2022
Main stack
React
Online Code Editor — React project screenshot

Overview

I built a browser-based code editor with two tools: a web editor where HTML, CSS and JavaScript render in a live preview, and a Markdown editor with a toolbar and a download button. It needs no sign-up or install, and your work is saved automatically in the browser.

Problem

Trying out a small page or writing a README should not need a project folder, an editor install or an account. Students and beginners often just want to type some HTML and see it work, then come back to it later.

Approach

I made two small tools in one React app. The web editor combines three code panes into one sandboxed preview that updates as you type. The Markdown editor adds a toolbar and a download button. Both save to the browser, so there is no server, no login and nothing to lose when a tab closes.

Outcome

Editors
2
Routes
3
Servers or accounts
0
Commits
36

What I built

  • Web editor with separate HTML, CSS and JavaScript panes using CodeMirror
  • Live preview in a sandboxed iframe that updates as you type
  • jQuery available inside the preview for quick experiments
  • Auto-closing tags and brackets, and syntax highlighting
  • Markdown editor with a formatting toolbar and GitHub-style rendering
  • Download the finished Markdown as a file
  • Automatic saving to the browser, restored when you come back
  • GitHub Actions workflow that tests every pull request

Architecture

System architecture

Diagram: a React app with editors and browser storage, no server.
A front-end-only app. The browser does all the work. Open full size ↗

Live preview loop

Diagram: type, combine, preview and save.
The three panes become one document in a sandboxed preview, and the result is saved on every change. Open full size ↗

Markdown workflow

Diagram: write, render, autosave and download.
The toolbar writes the Markdown syntax for you. Open full size ↗

Engineering decisions

  1. 01No backend on purpose

    The editor stores work in localStorage. That keeps it free to host, private by default and instant to open, with no account to forget.

  2. 02Preview in a sandboxed iframe

    User code runs inside an iframe built from the three panes. A bad script cannot break the editor around it.

  3. 03A tiny hook for saving

    One small useLocalStorage hook handles reading and writing, with a safe fallback when storage is blocked. Both editors share it.

  4. 04Tested on every pull request

    A GitHub Actions workflow installs, lints and builds each pull request before it can merge.

Need something similar?

Tell me what you are building and I will reply within one working day.

Start a project
↑↓ navigate↵ openesc closeCtrl K toggles this menu