JSON → CUE definitions

Client

Paste JSON to emit CUE #Definition blocks: nested objects become reusable definitions, arrays use open list syntax, and quoted labels appear when keys collide with CUE keywords—iterate with your local cue toolchain when you need validation or exports.

Review before wiring into modules

Output is a scaffold, not production policy. Layer optional fields, regex constraints, and package boundaries the same way you would when authoring CUE by hand—especially for APIs that send sparse objects or polymorphic payloads.

Learn more: JSON and CUE

Emit `#Definition` blocks with open lists (`[...T]`)—move constraints such as regex, defaults, and disjunctions into the CUE module you already run through `cue fmt` / `cue vet`.

Optional fields and null

A single JSON sample cannot show optional keys or null unions. Add `?`, `|`, or `_` after you inspect more responses so the policy matches the API instead of the lucky path.

Package layout

This scaffold uses `package config`; rename packages when you merge it into an existing module tree, and split large definitions into separate files when you need clearer imports.

JSON → CUE

?

Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.

Output lists open arrays as [...T] and nested JSON objects as #TypeName definitions—add optional markers, regex constraints, and package layout once you know the full API contract.

Common use cases

  • Sketch configuration shapes for Kubernetes, CI, or API contracts before tightening them with disjunctions and defaults in a real CUE module.
  • Compare a vendor JSON sample against a hand-written `#Service` block by pasting both sides through formatter and diff elsewhere.
  • Turn an HTTP response mock into a starting `#Envelope` definition when onboarding a new integration team.
  • Bridge product and platform discussions by sharing CUE syntax that mirrors the JSON payload ops already validated in staging.

Common mistakes to avoid

  • Treating one JSON response as exhaustive

    Optional keys, nullable fields, and unions do not appear in a single sample—extend the draft with `?`, `|`, or explicit `_` where APIs vary.

  • Expecting integer vs float fidelity

    JSON numbers map to unified `number` in this draft; split int and float manually when your module enforces discrete counters versus measurements.

  • Skipping rename conflicts with CUE keywords

    Unsafe identifiers become quoted field labels—rename to idiomatic CUE identifiers when you move output into a larger codebase.

FAQ

Does this run the `cue` command-line tool?

No. Generation is pure text in your browser. Install CUE locally when you are ready to run `cue fmt`, `cue vet`, or export JSON/YAML.

Why lists look like `[...T]`?

Open lists match typical JSON array payloads. Replace them with fixed tuples or comprehensions when you need exact lengths.

How does this relate to JSON Schema?

Both describe structure; CUE definitions are convenient when your team already scripts transforms with CUE. Use the JSON Schema page when you need draft-07 validation artifacts.

Common search terms

Phrases people search for that match this tool. See the full long-tail keyword index.

  • json to cue schema online
  • sample json to cue definitions
  • generate cue from json browser
  • cue list constraints from json

Related utilities you can open in another tab—mostly client-side.