tailwindlabs/tailwindcss · error · Error
Invalid value for --format: ${input}
Error message
Invalid value for --format: ${input} What it means
The `canonicalize` CLI subcommand accepts only three `--format` values: `text`, `json`, and `jsonl`. `parseFormat` does an exact-match comparison against these and throws for anything else, so a typo or an unsupported format fails fast with a descriptive message rather than producing malformed output.
Source
Thrown at packages/@tailwindcss-cli/src/commands/canonicalize/index.ts:289
let content = await fs.readFile(resolvedCssFile, 'utf8')
return __unstable__loadDesignSystem(content, {
base: path.dirname(resolvedCssFile),
})
}
function splitCandidateGroups(input: string) {
return input
.split(/\r?\n/g)
.map((line) => line.trim())
.filter((line) => line.length > 0)
}
function parseFormat(input: string): OutputFormat {
if (input === 'text' || input === 'json' || input === 'jsonl') {
return input
}
throw new Error(`Invalid value for --format: ${input}`)
}
function usageError(message: string): RunCommandLineResult {
return {
exitCode: 1,
stdout: helpMessage() ?? '',
stderr: message,
}
}
function splitCandidates(input: string) {
let trimmedInput = input.trim()
if (trimmedInput.length === 0) return []
return segment(trimmedInput, ' ')
.map((candidate) => candidate.trim())
.filter((candidate) => candidate.length > 0)
}View on GitHub (pinned to 16e94cbf7f)
Solutions
- Set `--format` to one of `text`, `json`, or `jsonl`.
- If invoking `parseFormat` programmatically, validate the input against the set `['text','json','jsonl']` before calling, and route failures through `usageError` to print help on stderr.
Example fix
# before tailwindcss canonicalize --format yaml # after tailwindcss canonicalize --format json
Defensive patterns
Strategy: validation
Validate before calling
const FORMATS = new Set(['text', 'json', 'jsonl'])
function safeParseFormat(input: string): OutputFormat | never {
if (!FORMATS.has(input)) {
process.stderr.write(`Invalid --format: ${input}. Valid: ${[...FORMATS].join(', ')}\n`)
process.exit(1)
}
return input as OutputFormat
} Type guard
function isOutputFormat(v: string): v is OutputFormat {
return v === 'text' || v === 'json' || v === 'jsonl'
} Prevention
- Validate --format against text/json/jsonl before invoking canonicalize.
- Drive the flag from a typed enum in scripts rather than free-form strings.
- Surface invalid values via usageError to print help on stderr.
When it happens
Trigger: Running `tailwindcss canonicalize --format xml ...` (or yaml, csv, pretty, etc.). The argument fails all three equality checks in `parseFormat` and throws at index.ts:289. Note: the result is intended to be turned into a usage error by the caller (`usageError`), but the raw throw surfaces if `parseFormat` is called directly.
Common situations: Scripting around the canonicalize command with a guessed format name, or a CI flag value coming from an env var that is empty or misspelled.
AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12).
Data as JSON: /api/errors/acabcaa0c8093376.
Report an issue: GitHub.