Sometimes it is faster to type than to click. Code mode shows your entire Buildan.app site as readable files: one HTML file per page, your header and footer, reusable components, and the styles as CSS. You edit them with a live preview beside you, and when you apply, the visual editor, the AI, publishing and export all keep working exactly as before.
Nothing is converted one way. Code mode and the visual editor are two views of the same site, so you can switch between them as often as you like.
What you need
- Any Buildan.app site. Code mode is available on every plan.
- A paid plan (Pro or Business) only if you want custom JavaScript to run on the published site, or a static build in the code download.
- Basic familiarity with HTML and CSS helps, but the examples below are short.
Open code mode
Step 1: Click Code in the top bar
Open your site in the editor and click Code in the top bar. You can also press ⌘K to open the command palette and choose Open code.
Step 2: Find your way around
Code mode has three parts:
- Files on the left:
site.json(pages, navigation, redirects and settings), the Pages (one HTML file each, with item templates such as[slug].htmlfor collections), Layout (header.htmlandfooter.html), Styles (site.cssandtheme.css) and Collections, which are read only here. - The code editor in the middle, with tabs for the files you have open. It colours HTML, CSS and JavaScript, completes tags and attributes as you type, and underlines mistakes.
- The live preview on the right. Use the buttons above it to switch between desktop, tablet and phone widths, or hide it.
Each element is one tag. Sections are <section>, headings are <h1> to <h6>, a link with a variant attribute is a button, and an image is <img>. Element ids are hidden to keep the code readable; turn on Show element ids with the eye button if you need them.
Edit and apply
Step 3: Change some HTML and watch the preview
Click in the code and type. The preview follows your typing before anything is applied, and the file gets a dot in the list to show it changed. The status at the top changes to 1 file changed.
Here the headline of the home page goes from "Bread worth waking up for" to "Sourdough worth waking up for":
<h1 data-name="Headline" motion="split-words-up delay:0.08 #am1">Sourdough worth <em>waking up</em> for</h1>Notice the motion attribute: animations are part of the code too, so editing text never loses them. Press ⌘F to search, and replace in one go from the same panel.
Step 4: Apply your changes
Click Apply (or press ⌘Enter). A short summary lists what will change, such as 1 element changed. Click Apply again to confirm. The whole change becomes one step in the history, so a single Undo reverts all of it.
If you leave without applying, your unapplied changes are kept on this device, so you can come back to them. Use Discard to throw them away.
Step 5: Write CSS for one breakpoint
Open styles/site.css. Every element has its own rule, using its class such as .n- followed by its id. Tablet styles live inside @media (max-width: 991px) and phone styles inside @media (max-width: 767px), exactly like the breakpoints in the visual editor.
This rule makes the headline smaller and centred on phones only:
@media (max-width: 767px) {
.n-6HVKAFrXrv { font-size: 44px; text-align: center; }
}Design tokens from your theme are written as variables, such as var(--wb-primary), and they live in styles/theme.css with your colour styles, text styles and uploaded fonts. Press ⌘S or click Format to tidy a file.
Step 6: Fix problems before they reach your site
Code with a mistake cannot be applied. The status bar shows how many problems there are, the line is underlined, and Show problems lists each one with its file, line and column. In this example an unknown tag, <wb-carousel>, is caught and the message lists the tags code mode does understand.
Your site is never touched by code that does not check out. Fix the line, or click Discard, and the status returns to No errors.
Step 7: Click the preview to find the code
Click any element in the preview and the editor jumps to its code and highlights it. It works the other way round too: put the cursor in a tag and the preview outlines that element.
Let AI write code
Step 8: Ask AI to write code
Click Ask AI in the code mode toolbar and describe what you want, mentioning the file. For example: "Write a collection list of the latest 3 recipes on pages/index.html". Click Send. The answer explains what it did and lists the files it edited. Click Apply to put it into the site, or Review as code to read it first.
The AI's code goes through the same checks as yours, so it cannot apply anything with errors.
Step 9: Read the dynamic list it wrote
Lists of collection items use the <wb-collection> tag. Everything inside it repeats once per item, and {{ item.field }} fills in each item's values:
<wb-collection source="recipes" sort="-published_on" limit="3" empty="Nothing here yet.">
<article>
<img src="{{ item.cover | img }}" alt="{{ item.title }}">
<p>{{ item.published_on }}</p>
<h3>{{ item.title }}</h3>
<a href="{{ item.url }}">Read more</a>
</article>
</wb-collection>Filters such as date, money, truncate: 120 and upper format values, and {% if %} and {% for %} blocks work inside lists and item pages. Other wb- tags cover forms (<wb-form>), galleries, sliders, tabs, accordions, data components such as <wb-chart> and <wb-table>, and store blocks such as <wb-products> and <wb-cart>. Unknown wb- tags are always reported as errors and never dropped silently.
Settings, download and phones
Step 10: Custom JavaScript and the code download
The settings button in the toolbar holds Custom JavaScript and Download code (zip).
Custom JavaScript lives in scripts/site.js and in <script> tags. It only runs on the published site (and in the preview if you turn on running scripts), never inside the editor, and only when you switch it on. It is part of the paid plans; on the Free plan your code is kept but does not run until you upgrade. Only add code you trust, because scripts can change your pages and send visitor data elsewhere.
Download code (zip) gives you every file plus a README describing the tags. On plans with code export it also includes a ready to host static build of the site.
Step 11: Edit code on your phone
On a phone, open the editor, tap the More menu and choose Code. Code mode switches to one pane: pick the file from the menu at the top, switch between Code and Preview, and tap Apply when you are done.
Tips and pitfalls
- Keep the element ids. When ids are shown, leave them in place. They keep history, comments and animations attached to the right element. New elements get an id automatically when you apply.
- Styles stay per element.
site.cssaccepts one rule per element class, plus states such as:hover, and the two breakpoint media queries. Other selectors are reported as errors, so styles can never leak into other elements. - Inline styles move. A
styleattribute is fine while you work; it is moved intosite.csswhen you format or apply. - Collections are read only here. Change fields and items in the CMS, then use them in code with
{{ item.field }}. - New pages and components. Use New page or New component at the bottom of the file list rather than creating files by hand.
- Generate as code. On the new site page you can tick Generate as code to have AI write a new site as these files from the start. The standard generation usually gives richer layouts, so try both.
Summary
Code mode turns your site into HTML and CSS files with a live preview. Click Code, edit pages, header, footer and styles, check the status bar for problems, and Apply to make the change one undo step. Use wb- tags for dynamic lists and components, ask AI to write code for you, and keep working on a phone when you are away from your desk.
Want to try it on your own site? Create a free account, or start with the editor tour if you are new to Buildan.app.


