KScript docs
EN

KScript

A small scripting language for automating your computer, building web pages and APIs, and making desktop apps. Scripts are XML or the brace-style .kscript format, and both run on Windows, macOS and Linux.

Try it

Switch between XML and .kscript to see the same script in both formats. To run an example, save it to a file and run it with kscript, or open these docs with kscript docs, where every example has a Run button.

<let name="name" value="'World'" />
<echo>Hello, $name!</echo>

<let name="people" value="[{ name: 'Joan', age: 82 }, { name: 'Sam', age: 35 }]" />
<for each="p" in="$people->sort(by: fn(p) => $p.age)">
  <echo>{ $p.name } is { $p.age }</echo>
</for>
$name = 'World'
echo "Hello, { $name }!"

$people = [{ name: 'Joan', age: 82 }, { name: 'Sam', age: 35 }]
for p in $people->sort(by: fn(p) => $p.age) {
  echo "{ $p.name } is { $p.age }"
}

Guides

Getting startedThis page walks through KScript in ten minutes. Examples are shown in the .kscript format, and each one can be switched…Installing KScriptKScript is one program, kscript , that runs scripts, serves sites, checks code and builds apps. It is a native program…The KScript languageThis is the reference for KScript 2 scripts: the core language every script and page has, the packages you import for…The .kscript formatKScript has two ways to write the same language. .kscript files use braces and new lines, like most programming…Types and validationKScript has built-in types for text that means something, called native types: email , url , ip , country , duration …Web pages: kscript servekscript serve runs a folder as a website. Every .html and .md page in it is a template: KScript elements sit directly in…ComponentsA component is a reusable part of a KScript website. Give it typed inputs and render it with a tag. State, event…Routes, controllers and middleware: KScript.HttpKScript.Http turns kscript serve into a server framework. A route file maps HTTP methods and paths to controllers. A…Desktop apps: KScript.UIKScript.UI lets a script open a native window on macOS, Windows or Linux. You describe the window's layout and its state…Programs: kscript compileWhen you share a script with someone, they shouldn't need to install kscript first. kscript compile turns a script into…Stylesheets: kscript cssA stylesheet often repeats the same values: a brand colour and its lighter and darker shades, a spacing scale, the…App folders: KScript.StorageMost apps keep a few files of their own: settings, saved data, a cache, recent files and logs. Each operating system has…Caching: KScript.CacheSome work is slow: a web request, reading a big file, a long calculation. When its answer doesn't change every time, you…Databases: KScript.DataKScript.Data lets you keep records in a database and read them back without writing SQL. You describe each table as a…Sign-in: KScript.AuthKScript.Auth gives a kscript serve app accounts that people sign in to. It keeps the users, hashes their passwords with…Queues and jobs: KScript.QueueSome work shouldn't make a person wait: sending an email, resizing a picture, calling a slow API. KScript.Queue lets you…Mail: KScript.MailMost apps send email: a welcome message, a receipt, a link to reset a password. KScript.Mail sends it with one command…Scheduling tasksSome work runs at set times rather than when someone asks for it: pruning old sessions every hour, emailing a report at…Documents: KScript.DocumentKScript.Document writes scientific and professional documents: papers, reports, letters and invoices. One script can…Testing scripts: kscript testTests let you change code without worrying that you broke something. KScript has a test framework built in, so there is…Debugging scriptsWhen a script gives the wrong answer, echo will often tell you why. When it doesn't, the debugger lets you watch the…Projects and generatorsA project is a folder with a kscript.json in it. The file tells every kscript command about the project: which scripts…Formatting: kscript fmtCode is easier to read when everyone lays it out the same way, and nobody should spend a review on spaces. kscript fmt…StandardsA team usually wants every project to follow the same house style: the same lint rules, the same indent, the same line…Error codesEvery problem kscript check and the editor report has a code, such as KS4001 . This page says what each one means and…AI assistants (MCP)AI coding assistants know a lot of languages, but they may not know KScript, or the version you have. kscript mcp gives…Coding agentsCoding agents such as Claude Code, Codex and Cursor work best when they know a project's own functions, types and rules…What changedKScript now has one way to write each thing. This page lists every spelling that was renamed or removed, with what to…RoadmapThese are ideas KScript is heading towards. The ones below aren't built yet, and the details may change.Built-in API gapsThis document tracks the built-in API work and the contracts that guided it. The tables under each section record the…