How Clean works

From your code to a running app

You write Clean code. Clean checks it and packs it into one small file. A server runs that file and gives your app what it needs, like a database.

The simple version

Three steps from idea to app

New to programming? This is all you need to know to start.

1

You write

You describe what your app does in .cln files, in plain, readable code.

2

Clean checks and packs it

The compiler finds mistakes before anything runs, then packs your app into one small file.

3

Clean Server runs it

Your app answers visitors. It can only use what the server allows, so it stays safe.

Think of your app as a sealed letter, and the server as the post office: it delivers the letter and fetches what the letter asks for.

Under the hood

The full picture

Three words you'll see below. WebAssembly is the small file your code becomes. The host is the program that runs it: Clean Server, or your browser. The host bridge is how your app asks the host for things like the database.

How a Clean Language app is built and run Your Clean code goes to the compiler. Frame plugins turn blocks like endpoints and data into plain Clean code. The compiler produces a server WebAssembly file and, for interactive pages, a browser WebAssembly file with a small loader. Clean Server runs the server file and provides the host bridge and server features. The browser runs the browser file through the loader. Command-line programs run with cln run. BUILD TIME Your code main.cln · app/**/*.cln · .html Frame plugins endpoints: · data · html: component: · auth: · jobs: turn each block into plain Clean code before it is compiled Compiler cln compile checks types, writes WebAssembly server.wasm frontend.wasm + loader.js The browser files exist only if your pages have interactive components. RUN TIME Clean Server runs server.wasm · one file, no dependencies Your app sealed in a WebAssembly sandbox · it can only ask, never reach out Server features HTTP routes, requests and responses, sessions, login Host bridge database, files, printing, time, crypto, outgoing HTTP Browser runs frontend.wasm loader.js from frame.ui the browser's host bridge: clicks, page updates, clipboard, timers you write no JavaScript Your terminal cln run app.cln command-line programs, scripts and tests Arrows in blue show where each WebAssembly file runs.

A Clean app is sealed in a sandbox. It can only use what the host offers, so a bug can't quietly reach your files or your network.

Follow one request

What happens when someone opens /api/notes

  1. Clean Server receives the request and finds the matching route inside server.wasm.
  2. Your handler runs in the sandbox and calls Note.find.
  3. That call becomes a request to the host: "run this query".
  4. Clean Server runs the query against the database and hands the rows back.
  5. Your handler turns them into JSON, and Clean Server sends the response.

Your code never touched a socket or a database connection. It only asked.

Why it's built this way

Safe, simple to ship, easy to change

Safe by design

WebAssembly can't open files, connect to the network or read memory outside its sandbox. The host decides what's allowed.

One file to deploy

No node_modules and no runtime to match. Copy the .wasm file next to Clean Server and start it.

Swap the outside, keep the code

Moving from SQLite to PostgreSQL changes a URL, not your app.

Small language, growing framework

Frame features are plugins, so new capabilities arrive without changing the language you know.

Tutorials

Learn it step by step

Short lessons that build on each other. Each one ends with code you can run.

21beginner

Types and Conversions

Understand Clean Language's four core types and how to convert between them. The type system catches mistakes before they reach production.

Start →
22intermediate

Functions in Depth

Write functions that call each other, return different types for different conditions, and build complex behavior from simple pieces.

Start →
23intermediate

List Operations

Everything you can do with a list — add items, access by index, check membership, iterate, and build new lists from existing ones.

Start →
24intermediate

The String Toolkit

A practical guide to Clean Language's string methods — the ones that appear in real programs, with examples that show when to reach for each one.

Start →
25intermediate

Designing Classes

Bundle data and behavior into a class. Write a constructor, define methods, and create multiple independent instances from the same template.

Start →
26intermediate

Class Inheritance

Extend a class with is and call the parent constructor with base(). Reuse behavior from a parent and add or override what the child needs.

Start →
27intermediate

Contracts with require

State function preconditions explicitly. require is documentation and enforcement in one line — the compiler and runtime guarantee the contract is honored.

Start →
28intermediate

Error Handling in Depth

Signal errors with error() and handle them at the call site with onError. Make error handling explicit, local, and readable.

Start →
29intermediate

Iteration Patterns

Master all iteration forms — range, step, list, while, break, and continue. Know which pattern fits each problem.

Start →
30intermediate

Language in Practice

Put it all together: build a word-frequency counter using classes, functions, lists, strings, and iteration. See how the pieces connect in a complete program.

Start →
Questions

Common questions

Is WebAssembly only for the browser?

No. It started in browsers, but it's a general format. Clean uses it on the server, in the browser and on the command line.

Is it slower than a native program?

WebAssembly is compiled to machine code before it runs, so app code runs close to native speed. Database queries and network calls run in the host at full native speed.

What can my app do that the host doesn't offer?

Nothing, and that's the point. If a capability isn't offered, the app can't use it.

Do I need to understand this to use Clean?

No. cleen, cln and Frame handle all of it. This page is for when you're curious, or deciding whether Clean fits your project.

Try it in two minutes

Install the toolchain and run your first program.

Copied!