---
title: Command line (total4)
project: Total.js V4
version: 0.0.99
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/reference/command-line/
updated: 2026-11-16T15:41:10.817Z
---

# Command line (total4)

> Every command of the total4 command-line tool.

The `total4` tool is installed with `npm install -g total4`. The guide [Command line (total4)](../../guides/command-line/) explains the commands with examples; this page lists every command, its arguments and its output.

## API

### total4 <command> [arguments]

Type: `command`

The command-line tool of the total4 package.

Installed with `npm install -g total4` (the `bin` entry of the package). The first argument is the command; `name`, `-name` and `--name` are the same command. Each run prints a header box with the version first. Without a command it prints `Use "total4 help" to list all commands.`, and an unknown command prints `Command "..." is invalid`.

Example: Install and list the commands
```bash
npm install -g total4
total4 help
```

### total4 help

Type: `command`

Prints the list of all commands.

Aliases: `h`, `-h`, `--help`. Prints one line for each command with its arguments and a short description.

Example: Show the help
```bash
total4 help
```

### total4 version

Type: `command`

Prints only the header with the version.

Aliases: `-v`, `--version`. The tool prints its header box, which contains the version of the framework, and ends.

Example: Show the version
```bash
total4 -v
```

### total4 <port>

Type: `command`

Serves the current directory as static files on the given port.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `port` | `Number` | yes |  | The port of the HTTP server. |

The number must be the first argument. The server runs in debug mode on `0.0.0.0`. A directory returns its `index.html`, or a generated directory listing with file sizes when there is none. HTML, scripts and styles are sent without compilation; `.less` files are served as `text/less`. Temporary files go to the temporary directory of the system. Stop it with `Ctrl+C`.

Example: Serve a static site
```bash
cd ~/www/landing
total4 8000
# open http://127.0.0.1:8000/
```

### total4 templates

Type: `command`

Prints the list of official project templates.

Downloads the list from GitHub and prints the name and description of each template. Without a connection it prints `Total.js templates are currently unavailable.`

Example: List templates
```bash
total4 templates
```

### total4 bundle [filename]

Type: `command`

Makes a bundle of the current directory.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | no | `app.bundle` | The name of the bundle file, with the `.bundle` extension. |

Writes all files of the current directory into one `.bundle` file and prints the directory, the file name, the number of files and the size. Excluded: `/bundle.json`, `/debug.js`, `/release.js`, `/index.js` with their `.json` and `.pid` files, `/package.json`, `/readme.md`, `/license.txt`, `/bundles/`, `/tmp/`, `/.src/`, `/.git/` and the output file. See [Application structure](../../guides/application-structure/) for how bundles are loaded.

Example: Bundle an application
```bash
cd ~/projects/eshop
total4 --bundle eshop.bundle
# copy eshop.bundle to /bundles/ of another application
```

### total4 package [filename]

Type: `command`

Makes a .package file of the current directory.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | no | `noname.package` | The name of the package file, with the `.package` extension. |

Works like `bundle`. Excluded: `/bundle.json`, `/debug.js`, `/release.js`, `/debug.pid`, `/package.json`, `/readme.md`, `/license.txt`, `/bundles/`, `/tmp/`, `/.git/` and the output file. Copy the result to `/packages/` of an application.

Example: Make a package
```bash
cd ~/packages/reports
total4 package reports.package
```

### total4 extract <filename>

Type: `command` · Since: `0.0.89`

Extracts a bundle or a package into the current directory.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | yes |  | The `.bundle` or `.package` file. |

Writes every file of the archive into the current directory, overwriting files with the same path, and prints the number of files and the size.

Example: Extract a bundle
```bash
mkdir restored && cd restored
total4 --extract ../eshop.bundle
```

### total4 minify <filename>

Type: `command`

Minifies a .js, .css or .html file.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | yes |  | The file to minify. |

Aliases: `-compress`, `-compile` (with one or two dashes). The file name is the last argument. Writes `<name>.min.<extension>` next to the file and prints `Minified: <path>`; other extensions are not written. A missing file prints `File not found`.

Example: Minify a script
```bash
total4 minify public/js/app.js
# writes public/js/app.min.js
```

### total4 translate

Type: `command`

Collects localizable texts of the application into translate.resource.

Alias: `-t`. Reads `.html` and `.js` files (and files with `sitemap` in their path) of the current directory and all its subdirectories. Collects `@(text)` markers (texts that start with `#` and a non-space character are skipped) and, in `.js` files, keys from `$.invalid('key')`, `.error('key')` and `.err('key')`. Writes `translate.resource` grouped by `// filename` comments and prints the number of texts. See [Localization](../../guides/localization/).

Example: Create a resource
```bash
cd ~/projects/eshop
total4 translate
cp translate.resource resources/sk.resource
```

### total4 translate "TEXT"

Type: `command`

Prints the resource line for one text.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `TEXT` | `String` | yes |  | The text to translate. |

When the argument is not an existing file, the tool prints the key (`T` and the base-36 hash of the text) and the text, ready to paste into a resource file.

Example: Key of one text
```bash
total4 translate "Add to cart"
```

### total4 translate <filename>

Type: `command`

Creates translate.resource from the lines of a text file.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `filename` | `String` | yes |  | A text file with one text per line. |

Each non-empty line of the file becomes one entry with a `T` hash key. The result is `translate.resource` in the current directory.

Example: Resource from a list of texts
```bash
total4 translate texts.txt
```

### total4 translatecsv

Type: `command`

Collects localizable texts into translate.csv.

Alias: `-c`. Reads `.html` and `.js` files of the current directory and its subdirectories and writes each unique `@(text)` marker as a row of `translate.csv` with the columns `Hash;Text;Translation`.

Example: CSV for a translator
```bash
total4 translatecsv
# send translate.csv to the translator
```

### total4 translate4 <source>

Type: `command`

Converts a resource with old numeric keys to Total.js 4 keys.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `source` | `String` | yes |  | The old resource file. |

Alias: `-4`. Keys like `T123` and `T-123` become `T` and the base-36 form of the number; other lines stay. The output name is the argument with `-new` inserted before its first dot.

Example: Convert an old resource
```bash
cd resources
total4 translate4 sk.resource
# writes sk-new.resource
```

### total4 diff <source> <target>

Type: `command`

Writes the differences between two resource files.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `source` | `String` | yes |  | The complete resource, for example from `translate`. |
| `target` | `String` | yes |  | The resource to check. |

Writes `<target>-diff.txt` next to the target with two sections: the keys of `source` that `target` misses ("Add to") and the keys of `target` that `source` does not have ("Remove from"), with their comments. Prints the counts and the output file.

Example: Find new texts
```bash
total4 translate
total4 diff translate.resource resources/sk.resource
# read resources/sk-diff.txt
```

### total4 merge <source> <target>

Type: `command`

Merges the texts of one resource into another.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `source` | `String` | yes |  | The resource with new texts. |
| `target` | `String` | yes |  | The resource to update. |

Goes through `target` and replaces the text of each key that `source` also has. Keys missing in `source` keep their text; keys only in `source` are not added. Writes `<target>-merged.txt` next to the target and prints the number of merged keys.

Example: Take translated texts
```bash
total4 merge sk-from-translator.resource resources/sk.resource
# writes resources/sk-merged.txt
```

### total4 clean <source>

Type: `command`

Aligns the keys of a resource file.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `source` | `String` | yes |  | The resource file. |

Pads all keys to one column and keeps comments and empty lines. Writes `<source>-cleaned.txt` next to the file.

Example: Tidy a resource
```bash
total4 clean resources/sk.resource
# writes resources/sk-cleaned.txt
```

### total4 edit <url>

Type: `command` · Since: `0.0.46`

Connects the current directory to the Total.js Code Editor.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | yes |  | The URL of the project in the Code Editor, with `?id=project`. |

Alias: `-e`. Opens a WebSocket connection to the project URL (`http` becomes `ws`) and lets the editor browse, read, create, save, rename, upload and remove files of the current directory and read its logs. Reconnects every 10 seconds. Prints `404 project not found` while the project does not exist and stops with `409 project is already open`.

Example: Open a project
```bash
cd ~/projects/eshop
total4 edit "https://code.example.com/?id=eshop"
```

### translate.resource

Type: `type`

The resource file written by the translate commands.

Starts with `// Total.js translation file` and the creation time. Each line is `key : text`; `total4 translate` groups the lines under `// filename` comments that list the files using the text. Rename it to `<language>.resource` and put it in `/resources/`.

Example: Content
```text
// Total.js translation file
// Created: 2024-05-10 09:30

// views/index.html
T1x9c0ks     : Add to cart
T3jf0a2      : Checkout
```

### translate.csv

Type: `type`

The CSV file written by total4 translatecsv.

The first row is `Hash;Text;Translation`. Each next row has the key, the text in double quotes and an empty translation.

Example: Content
```text
Hash;Text;Translation
T1x9c0ks;"Add to cart";
T3jf0a2;"Checkout";
```
