CLI
Overview
The formr-cli is a development tool for managing forms locally, validating schemas, and syncing with the API. It helps you work with forms in your development workflow.
Installation
Use via npx (no installation required):
npx formr-cli <command>Or install globally:
npm install -g formr-cliAuthentication
Login
Authenticate with the Formr API:
npx formr-cli loginThis will prompt for your API key and save it to ~/.formr/config.json.
Commands
init
initInitialize Formr in your project.
npx formr-cli initCreates a .formr directory with configuration files.
What it does:
Creates
.formrdirectorySets up configuration files
Prepares project for form development
infer
inferInfer form contract from HTML file or URL.
npx formr-cli infer ./public/contact.html --form contact
npx formr-cli infer https://example.com/form.html --form contactThis analyzes an HTML form and generates a Formr schema automatically.
Use cases:
Migrate existing HTML forms
Convert forms from other systems
Quick form schema generation
validate
validateValidate form contract.
npx formr-cli validate
npx formr-cli validate ./forms/contact.formr.jsonValidates form schemas for errors and issues before pushing to the API.
Checks:
Schema structure
Field definitions
Validation rules
Required fields
push
pushPush form contract to API.
npx formr-cli push
npx formr-cli push ./forms/contact.formr.json --applyUploads local form schemas to the API. Use --apply to update existing forms.
Behavior:
Creates new forms if they don't exist
Shows warning if form exists (use
--applyto update)Updates existing forms when
--applyis used
diff
diffShow diff between local and remote form.
npx formr-cli diff contact
npx formr-cli diff contact ./forms/contact.formr.jsonCompares local form schema with the version on the API to see what has changed.
Use cases:
Review changes before pushing
See what's different between local and remote
Verify updates
pull
pullPull form contract from API.
npx formr-cli pull contact
npx formr-cli pull contact --format yaml
npx formr-cli pull contact --format tsDownloads form schemas from the API. Supports multiple formats:
JSON (default)
YAML
TypeScript
Use cases:
Sync remote forms to local
Export forms for version control
Generate TypeScript types
types
typesGenerate TypeScript types from forms.
npx formr-cli types
npx formr-cli types --out ./types/formr.d.tsGenerates TypeScript type definitions for your forms based on their schemas.
Output:
Type definitions for form fields
Answer types
Form schema types
dev
devStart dev server with mock submit and preview.
npx formr-cli dev
npx formr-cli dev --port 7801Starts a local development server for testing forms without submitting to the API.
Features:
Preview forms locally
Mock form submissions
Hot reload
Development-friendly workflow
Configuration
Store API credentials in ~/.formr/config.json or use environment variables:
FORMR_API_KEY- API keyFORMR_API_URL- API URL (default:https://api.formr.dev)
Config File Location
~/.formr/config.jsonEnvironment Variables
export FORMR_API_KEY="sk_live_..."
export FORMR_API_URL="https://api.formr.dev"Workflow Examples
Complete Development Workflow
# 1. Initialize project
npx formr-cli init
# 2. Infer form from HTML
npx formr-cli infer ./public/contact.html --form contact
# 3. Validate schema
npx formr-cli validate
# 4. Push to API
npx formr-cli push --apply
# 5. Generate TypeScript types
npx formr-cli typesUpdating Existing Forms
# 1. Pull latest from API
npx formr-cli pull contact
# 2. Make local changes
# Edit forms/contact.formr.json
# 3. Check differences
npx formr-cli diff contact
# 4. Validate changes
npx formr-cli validate
# 5. Push updates
npx formr-cli push --applyLocal Development
# 1. Start dev server
npx formr-cli dev
# 2. Preview forms at http://localhost:7800
# 3. Test submissions locally
# 4. When ready, push to API
npx formr-cli push --applyFile Structure
After running init, your project will have:
.
├── .formr/
│ └── config.json
└── forms/
└── *.formr.jsonNext Steps
Development Tools - Other development tools
SDK Guide - JavaScript/TypeScript SDK
React Components - React components
API Reference - Complete API documentation
Last updated