CLI
Install and use @emailens/cli to analyze, preview, audit, and lint HTML emails in the terminal.
The @emailens/cli package runs the same @emailens/engine logic locally. No account is required for analyze, preview, audit, or lint. Optional hosted screenshots and share links use the Preview API with an API key.
Input can be HTML, MJML, Maizzle, or React Email (JSX). Format is inferred from the file extension unless you pass --format.
Install
npm install -g @emailens/cliOr run without installing:
npx @emailens/cli analyze ./emails/welcome.htmlRequires Node.js 18+.
Framework sources need extra packages
HTML works out of the box. Compiling other formats uses packages you install yourself, so the CLI stays small:
| Format | Install |
|---|---|
MJML (.mjml) | mjml |
| Maizzle | @maizzle/framework (v5 for HTML templates, v6 for .vue files) |
React Email (.tsx, .jsx) | sucrase, isolated-vm, plus react and @react-email/components |
React Email files run in a sandbox that only allows imports from react and @react-email/components. For a project with shared components, lint the exported HTML instead. See React Email.
Commands
| Command | Purpose |
|---|---|
emailens analyze <file> | Per-client compatibility scores and CSS warnings |
emailens lint <file|glob> | CI-friendly unified issue list with exit codes |
emailens preview <file> | Full pipeline: transforms, scores, dark mode; optional screenshots |
emailens audit <file> | Compatibility plus spam, links, accessibility, images, and related checks |
emailens export <file> | Self-contained HTML or JSON report on disk |
emailens fix <file> | AI-assisted fixes (requires ANTHROPIC_API_KEY and optional SDK) |
emailens clients | List supported client IDs |
Run emailens --help or emailens <command> --help for the full flag list on your installed version.
analyze
Quick compatibility pass with a score table and grouped warnings.
emailens analyze email.html
emailens analyze email.html --clients gmail-web,outlook-windows
emailens analyze email.html --json
cat email.html | emailens analyze -- -To read from stdin, pass -- -. A bare - is not accepted.
Source positions (line/column in warnings) are reported for HTML input only. Compiled MJML, JSX, and Maizzle omit positions because line numbers would refer to generated output, not your source file.
lint
Use this in pre-commit hooks and CI. Exit codes:
0, no errors (and no--fail-on-warning/--max-warningsfailure)1, at least one error-severity issue2, warnings only when--fail-on-warningis set, or--max-warningsexceeded
emailens lint 'emails/*.html'
emailens lint email.html --json
emailens lint email.html --fail-on-warning
emailens lint email.html --skip spam,linkslint takes one path or one single-level glob. Quote the glob so the CLI expands it, not your shell: any argument after the first is ignored. ** and {a,b} are not supported. To lint a tree, run it once per file:
find emails -name '*.html' -print0 | xargs -0 -n1 emailens lintSee Project config for .emailensrc / package.json emailens rules shared with the VS Code extension.
GitHub Actions
For a dedicated Action with PR annotations, see GitHub Action.
Local lint in a workflow:
- run: find emails -name '*.html' -print0 | xargs -0 -n1 npx -y @emailens/cli lint --fail-on-warningpreview
Runs transforms, analysis, and dark mode preview. --screenshots renders locally and needs a Browserless instance: set BROWSERLESS_URL and install playwright-core. For hosted screenshots with no setup, use the MCP server or the API.
emailens preview email.html
emailens preview email.html --dark-mode
emailens preview email.html --jsonaudit
Single-file comprehensive report (compatibility plus content and deliverability-style checks). Use lint when you need CI exit codes across many files.
emailens audit email.html
emailens audit email.html --json --skip spamShared flags
Most file commands accept:
| Flag | Description |
|---|---|
--format, -f | html, jsx, mjml, maizzle |
--clients, -c | Comma-separated client IDs |
--json | Machine-readable output |
--quiet, -q | No spinners or decorative output |
More detail
Command tables, .emailensrc precedence, and CI examples are also documented in the CLI README on GitHub.