# Code editor

> Open and edit a document's HTML, CSS, JavaScript, or text uploads in the browser with the built-in CodeMirror editor.

Source: https://hyperclay.com/docs/code-editor/

Hyperclay includes a browser code editor built on CodeMirror so you can inspect and edit the source code of any malleable document or text upload directly in your workspace.

## Open a document in the code editor

You can open the code editor in two ways:

- In the workspace, open a document and switch to its **Code** tab (or open the **Code** panel alongside the document). Click **Close Code** to return to the rendered document.
- Prefix a document's URL path with `/_/edit/`, such as `<your-username>.hyperclay.com/_/edit/<document>.html`.

You can also open text [uploads](https://hyperclay.com/docs/uploads/) in the dashboard and edit them in the **Code** tab. Supported text formats include `.txt`, `.md`, `.markdown`, `.json`, `.html`, `.htm`, `.htmlclay`, `.jsx`, `.css`, `.js`, `.mjs`, `.csv`, `.tsv`, `.xml`, `.yml`, `.yaml`, `.log`, and `.svg`. Binary uploads or files that are not valid UTF-8 text cannot be opened in the code editor (`This file cannot be opened as text.`).

## Edit and save

The CodeMirror editor provides:

- Syntax highlighting for HTML, CSS, JavaScript, JSON, Markdown, and SVG
- Auto-indentation and bracket matching
- Line numbers, search, and multi-select with `Cmd+D` (`Ctrl+D` on Windows and Linux)

While you have unsaved edits in the editor, the header status reads `Unsaved changes`. Click **Save** or press `Cmd+S` (`Ctrl+S` on Windows and Linux) to write your changes. Once the save finishes, the status updates to `Saved <time ago>`. Hyperclay saves the markup you wrote without reformatting it. One exception: if the document carries a block editor format marker (`<meta name="clay-blockeditor-format">`) and your edit removes it, Hyperclay puts the marker back, so an older editor can never open the document and lose content it cannot read.

If someone else (or another open tab) saves the file while you have it open in the code editor, a banner warns `This file changed on the server.` Click **Save over theirs** only if you want your editor buffer to replace the newer version on the server. Every save records a version in [Version history](https://hyperclay.com/docs/version-history/).

## Who can use the code editor

Editing code requires an active [Personal or Maker plan](https://hyperclay.com/docs/billing/) on your own personal account.

| Context | Who can edit code |
|---|---|
| **Your own workspace** | You, while your account has an active Personal or Maker plan |
| **[Team](https://hyperclay.com/docs/teams/) workspace** | The team **Owner** and team **Editors**, provided their own personal account is on a Personal or Maker plan |
| **Team Viewer** | No (`You cannot edit this site's code.`) |
| **[Share links](https://hyperclay.com/docs/share-links/) and [one-document shares](https://hyperclay.com/docs/share-with-a-person/)** | No |

> [!NOTE]
> On a team, code editing follows the person rather than the team's subscription. A team editor whose personal account does not have an active paid plan can still edit documents on the page, upload files, and rename, move, or trash documents, but sees `You cannot edit this site's code.` in the **Code** panel.

## Alternative: Browser Developer Tools

Because a malleable document saves its own live DOM, you can also use your browser's built-in Developer Tools to make structural edits:

1. Open your document while signed in with edit rights and [edit mode](https://clayjs.com/docs/edit-mode/) active.
2. Press `F12` (or `Cmd+Option+I` on macOS) to open Developer Tools and switch to the **Elements** panel.
3. Double-click elements or attributes in the DOM tree to edit the HTML in place.
4. Save the document (`Cmd+S` or `Ctrl+S`, or let [ClayJS](https://clayjs.com/docs/guide/saving/) save automatically) to persist your DOM changes back to the file.
