CLI Reference

The witan CLI provides document reading, spreadsheet automation, workbook verification, and authentication commands.

Installation

macOS and Linux

curl -fsSL https://witanlabs.com/install.sh | sh

The install script downloads the latest release artifact, verifies its checksum, and installs witan to /usr/local/bin by default.

PyPI

# Zero-install one-shot
uvx witan xlsx render report.xlsx -r "Sheet1!A1:Z50"

# Persistent install
pip install witan

npm

# Zero-install one-shot
npx witan xlsx render report.xlsx -r "Sheet1!A1:Z50"

# Persistent install
npm install witan

The npm package requires Node.js 22 or later.

Manual Download

Use the latest GitHub release artifacts:

Platform Artifact
macOS, Apple Silicon witan-darwin-arm64.tar.gz
macOS, Intel witan-darwin-amd64.tar.gz
Linux, x86_64 witan-linux-amd64.tar.gz
Linux, ARM64 witan-linux-arm64.tar.gz
Windows, x86_64 witan-windows-amd64.zip
Windows, ARM64 witan-windows-arm64.zip
curl -fsSL https://github.com/witanlabs/witan-cli/releases/latest/download/witan-darwin-arm64.tar.gz | tar -xz
install -m 0755 witan /usr/local/bin/witan

Replace witan-darwin-arm64.tar.gz with the artifact for your platform. https://witanlabs.com/dl/<artifact> URLs are aliases for the same files.

Global Options

witan [flags] <command>
Flag Environment Description
--api-key <key> WITAN_API_KEY API key for Witan requests.
--api-url <url> WITAN_API_URL Override the Witan API base URL.
--stateless WITAN_STATELESS Send file bytes with each request; do not reuse uploaded revisions.
--version Print CLI version and API version.
--help, -h Show help.

Transport mode is credential-dependent. Without credentials, the CLI uses stateless mode: each command sends workbook bytes and does not reuse a server-side file cache. With credentials, the CLI uses files-backed mode by default: it uploads workbook revisions and reuses them across commands. Pass --stateless or set WITAN_STATELESS=1 / true to force stateless mode even when credentials are available.

Workbook inputs must be 25 MB or smaller.

Authentication and Environment

The personal tier does not require an API key. For organization-backed requests, either sign in with witan auth login or pass an API key from app.witanlabs.com/~/settings/api-keys.

export WITAN_API_KEY="sk_..."

On Windows PowerShell:

$env:WITAN_API_KEY = "sk_..."

Environment variables:

Variable Description Default
WITAN_API_KEY API key for organization-backed requests.
WITAN_API_URL Custom API endpoint. https://api.witanlabs.com
WITAN_STATELESS Set to 1 or true to process files without server-side caching. Off unless unauthenticated

Zero Data Retention

Stateless mode is active automatically when no credentials are available, and can be forced with WITAN_STATELESS=1 or --stateless. In stateless mode, each command sends file bytes for that request and does not reuse a server-side file cache:

export WITAN_STATELESS=1
witan xlsx render confidential-report.xlsx -r "Sheet1!A1:Z50"

The trade-off is that each command re-uploads the file. Repeated operations are slower than authenticated files-backed mode, but the command avoids server-side file caching.

Commands

Command Purpose
witan auth Sign in, inspect authentication status, or sign out.
witan read Extract text or outlines from source documents.
witan xlsx calc Recalculate formulas or verify cached values.
witan xlsx exec Execute JavaScript against a workbook.
witan xlsx lint Run semantic spreadsheet diagnostics.
witan xlsx render Render a sheet range as PNG or WebP.
witan xlsx rpc Run newline-delimited workbook RPC over stdio.

witan auth

Manage local credentials for organization-backed requests.

witan auth login
witan auth status
witan auth status --json
witan auth logout

witan auth login

Starts browser-based device-code sign-in, exchanges the device code for a session token, asks for an organization if more than one is available, and saves the session locally.

For non-interactive environments, use --api-key or WITAN_API_KEY.

witan auth status

Shows the active credential source, validation status, active organization when known, and ignored lower-priority credentials.

Flag Description
--json Print raw JSON authentication status.

witan auth logout

Attempts to revoke the current server session, then removes locally saved session credentials. If no session exists, it exits successfully.

witan read

Extract text content or document outlines from source material.

witan read <file-or-url> [flags]

Supported inputs include local files and HTTP(S) URLs.

Format Extensions Output
PDF .pdf Plain text via page ranges.
Word .doc, .docx Markdown.
PowerPoint .ppt, .pptx Slide text.
HTML .html, .htm Markdown.
Text .txt, .md, .csv, .json, .xml, .yaml, .toml Text with line offsets.
Flag Description
--pages <range> PDF page range, such as 1-5 or 1,3,5.
--slides <range> Presentation slide range, such as 1-3.
--offset <n> Start line, 1-indexed.
--limit <n> Maximum lines to return.
--outline Show document structure instead of content.
--json Print the full JSON response.

Examples:

witan read report.pdf --outline
witan read report.pdf --pages 1-5
witan read slides.pptx --slides 1-3
witan read notes.docx --offset 50 --limit 100
witan read https://example.com/report.pdf --outline
witan read data.csv --json

witan xlsx

Spreadsheet commands operate on .xls, .xlsx, and .xlsm workbooks. The CLI automatically corrects mismatched .xls/.xlsx extensions when file bytes reveal the other Excel format.

witan xlsx [--json] <command>
Flag Description
--json Output raw JSON instead of human-formatted summaries. Applies to xlsx subcommands that return structured output.

witan xlsx exec

Execute JavaScript against a workbook. The CLI Scripting page covers the scripting surface; this section is the command shape.

witan xlsx exec <file> [flags]

Provide exactly one code source: --code, --script, --stdin, or --expr.

Flag Default Description
--code <js> Inline JavaScript source.
--script <path> Path to a JavaScript file.
--stdin false Read JavaScript source from stdin.
--expr <expr> Single-expression shorthand; wraps as return (<expr>);.
--input-json <json> {} JSON value passed to the script as input.
--locale <name> Environment-derived Execution locale. Falls back to WITAN_LOCALE, then LC_ALL, LC_MESSAGES, and LANG.
--stdin-timeout-ms <ms> 2000 Maximum time to wait for EOF when reading --stdin; 0 disables.
--timeout-ms <ms> 0 Execution timeout override. 0 uses the server default.
--max-output-chars <n> 0 Stdout capture limit override. 0 uses the server default.
--create false Create a new .xlsx workbook instead of opening an existing file.
--save false Write returned workbook bytes to the target path.

Exit codes:

Code Meaning
0 Script completed with ok: true.
1 Transport/API error, invalid request, or script completed with ok: false.

witan xlsx rpc

Run newline-delimited xlsx RPC over stdio. Use this for persistent low-latency workbook sessions and SDK integrations.

witan xlsx rpc <file> [flags]

The CLI opens the workbook session. Input lines should not include a workbook field.

{"id":"1","op":"listSheets","args":{}}
{"id":"2","op":"readRange","args":{"address":"Sheet1!A1:B10"}}
{"id":"3","op":"save","args":{}}
Flag Default Description
--hint <value> Sheet name or address hint for lazy workbook loading.
--locale <name> Environment-derived Execution locale. Falls back to WITAN_LOCALE, then LC_ALL, LC_MESSAGES, and LANG.
--create false Create a new .xlsx session. The file is written only after a save operation.

Stdout contains one redacted JSON response per request. Stderr is reserved for CLI diagnostics.

witan xlsx calc

Recalculate formulas and update cached values, or run non-mutating verification with --verify.

witan xlsx calc <file> [flags]
Flag Default Description
--range, -r <address> Entire workbook Sheet-qualified range to seed recalculation from. Repeatable.
--show-touched false Print recalculated cells with formulas and computed values.
--verify false Do not overwrite the workbook; exit 2 if errors exist or values changed.

Exit codes:

Code Meaning
0 Recalculation completed with no reported formula errors.
1 Transport, API, file, or request error.
2 Formula errors were found. In --verify mode, cached values may also have changed.

witan xlsx lint

Run semantic formula and layout checks.

witan xlsx lint <file> [flags]
Flag Default Description
--range, -r <address> Entire workbook Sheet-qualified range to lint. Repeatable.
--skip-rule, -s <id> Rule ID to skip. Repeatable.
--only-rule <id> Run only these rule IDs. Repeatable.

Exit codes:

Code Meaning
0 No error- or warning-severity diagnostics.
1 Transport, API, file, or request error.
2 At least one error- or warning-severity diagnostic was reported.

witan xlsx render

Render a sheet-qualified range as a PNG or WebP image.

witan xlsx render <file> [flags]
Flag Default Description
--range, -r <address> Required Sheet-qualified range to render.
--dpr <n> Auto Device pixel ratio from 1 to 3.
--format <fmt> png Output image format: png or webp.
--output, -o <path> Temp file Write image to this path.
--diff <path> Compare against a baseline PNG and write a highlighted PNG diff. Requires PNG output.

Every invocation prints the output image path and render metadata. Large images may be downscaled by vision models; reduce the range or DPR when the output exceeds 1568 px on either axis.

Supported Workbook Formats

  • .xlsx (Office Open XML)
  • .xls (Excel 97-2003)
  • .xlsm (macro-enabled; macros are preserved but not executed)