Guide / CLI Reference

Installation

The 4less binary is available after installing the package:

npm install @dzhonragon/4less

Add to package.json scripts or run via npx:

npx 4less --help

Synopsis

4less [options] [file]

Options

FlagShortDescription
--eval -eCompile inline 4less code and print to stdout
--output -oWrite output to a file instead of stdout
--watch-wWatch file for changes and recompile on save
--format -fOutput format: html (default), react, vue, astro, json
--version-vPrint version and exit
--help-hShow help and exit

Examples

Compile inline code and print to stdout:

4less -e 'h1 "Hello, world"'

Compile a file to HTML (default):

4less template.4l

Compile to React and write to a file:

4less template.4l --format react --output src/Template.jsx

Compile to Vue:

4less template.4l --format vue --output src/Template.vue

Compile to Astro:

4less template.4l --format astro --output src/Template.astro

Compile to JSON (AST representation):

4less template.4l --format json

Watch mode — recompiles every time the file is saved:

4less src/page.4l --output dist/page.html --watch

Combine output file with watch and a specific format:

4less src/page.4l --format react --output src/Page.jsx --watch

Print from stdin:

echo 'h1 "Hello"' | 4less

Exit Codes

CodeMeaning
0Compilation succeeded
1Parse error or invalid flag — details printed to stderr