Built-in types
Every type a field, parameter or variable can be declared as, without importing anything: age: int, email: email, tags: string[]. Add ? to allow null and [] for a list.
Rules go in brackets after the type: string(min: 1, max: 200), int(min: 0), string(pattern: /^[a-z]+$/), string(one_of: [draft, live]), handle(not: [@admin]). Every type takes min, max, pattern, one_of and not; the options column lists what a type takes as well. More in Types and validation.
Values
| Type | What it holds |
|---|---|
| string | Text. Quoted with ' (as written) or " (with $name and { } filled in). |
| int | A whole number: 42, -7. A number with a fraction isn't an int. |
| float | A number that may have a fraction: 0.5, 3.14. |
| number | Any number, whole or not. |
| bool | true or false. |
| list | A list of values: [1, 2, 3]. T[] is a list of T, such as string[]. |
| map | Names and values: { name: 'Joan', age: 82 }. |
| fn | A function: a lambda fn(x) => $x * 2, or a declared function passed as @name. |
| date | A date and time: @now(), @today(), '2026-11-19'->to_date(). |
| markdown | A Markdown document, from a text block tagged markdown. See Documents. |
| latex | A LaTeX document, from a text block tagged latex. See Documents. |
| formatted_file | Source code from a text block tagged with a file type such as ps1, with .extension and .text. |
| document | A document built with KScript.Document, ready to save as PDF, Word, HTML or Markdown. |
| any | Any value. The type a field or parameter has when none is given. |
Native types
Values that are text underneath, checked and tidied when they are made: an email is lower-cased and must have an @, a url must have a scheme and host. Where the type is expected you can write the value without quotes (timeout: 30s, country: GB), and each has fields and methods of its own.
| Type | What it holds | Example | Options |
|---|---|---|---|
| base64 | Base64 text (standard or URL-safe). ->decode() gives the text it holds. | aGVsbG8= | |
| card | A payment card number, checked with the Luhn digit. It prints masked apart from the last four digits. | '4242 4242 4242 4242' | |
| cidr | A block of IP addresses: an address, / and a prefix length, such as 10.0.0.0/8. | 10.0.0.0/8 | |
| color | A colour: #rgb, #rrggbb, #rrggbbaa, rgb(...) or a CSS name. Kept as lowercase #rrggbb (#rrggbbaa with alpha). | #ff8800 | |
| country | An ISO 3166 country code. Two-letter, three-letter and English names are read; it is kept as two capitals, such as GB. | GB | |
| cron | A cron schedule of five fields (minute hour day month weekday), or @daily, @hourly and the like. | '*/15 9-17 * * mon-fri' | |
| csv | Text that holds valid CSV, such as a ```csv block. ->cells() reads its rows, columns and cells. | 'name,age' | |
| currency | An ISO 4217 currency code, kept in capitals: GBP, USD, EUR. | GBP | |
| date_format | How a date is written, such as dd-MM-yyyy or d MMMM yyyy, HH:mm: dd is the day, MM the month, yyyy the year, HH the hour and mm the minute. Text goes in quotes ('at' HH:mm). | dd-MM-yyyy | |
| domain | A domain name such as example.com or api.example.co.uk, lowercased, without a trailing dot. | example.com | |
| duration | A length of time: 1h30m, 90s, 2d, 5y10mo or ISO 8601 such as PT1H30M. Kept in its short form. | 1h30m | |
| An email address such as joan@example.com. Spaces are trimmed and the domain is lowercased. | joan@example.com | domains | |
| file_path | Where a file or folder is: ./data/input.txt from the script's folder, ../shared/rates.json from the folder above, or ~/notes.md from the home folder. Quote one that is absolute or has spaces: '/var/log/app.log', 'C:\Reports\May 2026.pdf'. | ./data/input.txt | |
| handle | @ followed by letters, digits, _, . or -: a username such as @joan. Lowercased. | @joan | |
| hex | Hexadecimal digits, such as a hash: a3f9c0. Lowercased; 0x is dropped. | a3f9c0 | bytes |
| iban | An international bank account number, checked with its mod-97 digits. Kept in capitals without spaces. | GB82WEST12345698765432 | |
| ip | An IPv4 or IPv6 address, written the standard way: 192.168.0.1 or 2001:db8::1. | 192.168.0.1 | version |
| json | Text that holds valid JSON. ->convert(from: json) gives the value. | '{"a": 1}' | |
| jwt | A JSON Web Token: three base64url parts. Its claims can be read; its signature isn't checked. | 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.sig' | |
| locale | A language tag (BCP 47) such as en, en-GB or pt-BR, in its usual case. | en-GB | |
| mac | A network card's MAC address, written as six lowercase pairs: 00:1a:2b:3c:4d:5e. | 00:1a:2b:3c:4d:5e | |
| mime | A media type such as text/html or application/json, lowercased, with any parameters. | application/json | |
| money | An amount with a currency. Write GBP9.50 directly in expressions. Typed money also accepts text such as 'GBP 9.50', '£9.50' and '$12'. Displays the code and the currency's decimal places. | GBP9.50 | rates |
| password | A secret. It prints as ********, can't be compared with ==, and is hashed to be stored. | 'correct horse battery staple' | upper, lower, digit, symbol, common, score, algorithm |
| phone | A phone number in E.164: + then the country code and number, 8 to 15 digits. Spaces, dots, dashes and brackets are dropped. | +447700900123 | countries |
| port | A network port, a whole number from 1 to 65535. | 8080 | |
| regex | A regular expression with flags i, m, s and x, written /.../ in code. | /^[a-z]+$/i | |
| semver | A semantic version such as 1.4.2, 2.0.0-beta.1 or 1.0.0+build.5. A leading v is dropped. | 1.4.2 | |
| slash_path | Names joined by /, such as /docs/getting-started or /My Apps/Notes: a page, menu or category path rather than a file. It always starts with /, so home is /home. Spaces around each name, empty parts, . and a trailing / are dropped, and .. goes up one. | /docs/getting-started | |
| slug | Lowercase words joined by -, for URLs: my-first-post. | my-first-post | |
| timezone | An IANA time zone such as Europe/London or America/New_York, or UTC. | Europe/London | |
| url | An absolute http, https, ftp, ws or wss URL. The scheme and host are lowercased. | https://example.com/docs?page=2 | schemes, hosts |
| uuid | A UUID, versions 1 to 8 and the nil and max UUIDs, lowercased to 8-4-4-4-12. | 3f2a8c1e-9b7d-4c2a-8e1f-0a9b8c7d6e5f | v |