--json flag. JSON (JavaScript Object Notation) is a structured data format that scripts and programs can easily parse. Use this when you want to process command output programmatically instead of reading it as plain text.
Enabling JSON Output
Add--json to any command:
Output Format
Success Response
Error Response
Command-Specific Output
mizu version --json
mizu new --list --json
mizu new --json
Success:
mizu new --dry-run --json
Same format as mizu new --json, but files are not written:
mizu dev --json
The dev command emits NDJSON (newline-delimited JSON) with lifecycle events:
Event Types
| Event | Description | Fields |
|---|---|---|
starting | About to start process | message |
started | Process started | message (includes PID) |
signal | Received shutdown signal | message (signal name) |
timeout | Graceful shutdown timed out | message |
stopped | Process exited | message, exit_code |
error | Error occurred | message, exit_code |
Event Schema
Error Codes
| Code | Description |
|---|---|
missing_template | Template flag required but not provided |
unknown_template | Specified template doesn’t exist |
path_error | Invalid path (traversal, absolute, etc.) |
conflicts | Files would be overwritten (use —force) |
plan_error | Error building execution plan |
apply_error | Error writing files |
list_error | Error listing templates |
Parsing JSON Output
jq Examples
Bash Script
Python
Go
Streaming Events (mizu dev)
Formizu dev --json, parse events line by line:
Bash
Node.js
Best Practices
Always Handle Both Success and Error
Capture stderr for Errors
Use jq for Safe Parsing
See Also
- Global Flags - All CLI flags including
--json - Exit Codes - Return codes for automation
- mizu dev - Development server with streaming events