Skip to content
Latchkey

cue export: Render CUE to JSON or YAML

cue export evaluates CUE files into a single concrete value and serializes it as JSON (default) or YAML.

CUE unifies data and schema in one language: constraints and values are the same thing. cue export is how you turn validated CUE into deployable config.

What it does

cue export loads the CUE files/package, unifies them into one concrete value, and serializes it. It fails if the value is not concrete (still has open constraints) or if two sources conflict. --out selects json (default), yaml, or text.

Common usage

Terminal
cue export ./config
# emit YAML instead of JSON
cue export ./config --out yaml > config.yaml
# export a specific expression with a tag injected
cue export -e deployment -t env=prod ./config --out yaml

Options

FlagWhat it does
--out <fmt>Output format: json (default), yaml, text
-e, --expression <expr>Export a specific field/expression, not the whole value
-t, --inject <key=value>Inject a value for a @tag() in the CUE
-o, --outfile <path>Write to a file (format inferred from extension)
--forceOverwrite an existing output file

In CI

Use cue vet to validate against schema first, then cue export to render. Inject environment-specific values with -t key=value against @tag() fields rather than maintaining parallel files. Export to an artifact and diff before apply; because CUE unification is deterministic, a diff is a real change.

Common errors in CI

"conflicting values X and Y" is CUE's signature error: two sources set the same field to incompatible values, and unification cannot reconcile them. "some instances are incomplete; use the -e flag ... or --force" or "cannot convert incomplete value" means a field is still an open constraint (e.g. port: int) with no concrete value. "field not allowed" means a value violates a closed struct/schema.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →