SchemaLens CLI

Diff SQL schemas and generate migrations from your terminal. Zero install with npx. The exact same engine as the web app — locally, offline, and scriptable.

npx schemalens-cli diff old.sql new.sql
ðŸ“Ķ 1.0.0 ⚡ Zero dependencies 🔒 100% offline 🐧 Linux / Mac / Windows

Why use the CLI?

Some developers prefer the terminal. We get it. The CLI runs the same custom parser and diff engine as the browser — no network, no API keys for basic usage.

⚡ Instant

No install required. Run npx schemalens-cli and diff schemas immediately. Perfect for one-off checks.

🔒 Private

Your SQL never leaves your machine. The CLI runs entirely locally with zero network calls for parsing and diffing.

ðŸĪ– CI-Ready

JSON output and strict mode make it easy to integrate into GitHub Actions, GitLab CI, or any CI/CD pipeline.

📄 Multiple Formats

Pretty-printed terminal output, JSON for machines, Markdown for PRs, and raw SQL for immediate execution.

ðŸ›Ąïļ Breaking Change Guard

Set SCHEMALENS_STRICT=1 to exit with code 2 when breaking changes are detected. Block dangerous migrations automatically.

ðŸŽŊ Risk Scoring

Every diff gets a risk score (0-100) based on change severity. Surface high-risk schema changes before they hit production.

See it in action

Diff two schemas and get a colorized report with breaking changes, risk score, and migration preview.

bash — schemalens-cli
$ npx schemalens-cli diff schema-v1.sql schema-v2.sql --dialect postgres

SchemaLens Diff Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✓ Tables added: 2
✗ Tables removed: 0
~ Tables modified: 3

Risk Score: 42 / 100 (Medium)
Breaking Changes: 1

# Migration Preview (first 5 lines)
ALTER TABLE users DROP COLUMN phone;
ALTER TABLE orders ADD COLUMN tracking_id VARCHAR(64);
CREATE TABLE audit_log (...);

# Export full migration with Pro
$ npx schemalens-cli diff schema-v1.sql schema-v2.sql --format sql --output migration.sql

Output formats

Choose the format that fits your workflow. All formats are available in the free CLI.

ðŸŽĻ

Pretty

Colorized terminal output with summary, risk score, and migration preview. Default.

ðŸĪ–

JSON

Machine-readable output for CI/CD pipelines, custom scripts, and automation.

📝

Markdown

Human-readable report perfect for PR descriptions and team documentation.

⚙ïļ

SQL

Ready-to-run ALTER TABLE and CREATE TABLE script for your target dialect.

Supported dialects

One CLI. Five SQL dialects. Switch with a single flag.

🐘PostgreSQL
🐎MySQL / MariaDB
ðŸŠķSQLite
ðŸŸĶSQL Server
ðŸ”ķOracle

CLI vs Web App

Same engine. Different interfaces. Pick what fits your workflow.

FeatureCLIWeb App
Install required❌ No (npx)❌ No (browser)
Internet required❌ No⚠ïļ For page load only
Visual diff viewer❌ Terminal only✅ Interactive UI
Shareable links❌ No✅ Yes
CI/CD integration✅ Native✅ Via API
Export formatsJSON / Markdown / SQLMarkdown / PDF / SQL / JSON / Prisma / Drizzle
Breaking change guard✅ Exit code 2✅ Visual warning
Free tier limit10 tables10 tables
Pro unlockLicense keyLicense key

Use it in CI/CD

Fail the build when breaking schema changes are detected.

.github/workflows/schema-diff.yml
- name: Diff schemas
  run: |
    npx schemalens-cli diff \       schemas/production.sql \       schemas/staging.sql \       --dialect postgres \       --format markdown \       --output diff-report.md
  env:
    SCHEMALENS_STRICT: 1

# This step fails (exit code 2) if breaking changes are found

Full CI/CD Guide →

Upgrade to Pro for unlimited diffs

The CLI free tier handles up to 10 tables per diff. Pro unlocks unlimited schemas, full SQL export, and all future CLI updates.

Get Pro — $12/mo Try the Web App

Or run npx schemalens-cli right now — no signup needed.