YAML to Zod converter

Convert YAML to Zod 4 schemas from a sample YAML file, to validate config at runtime and get its TypeScript type with z.infer.

YAML

Zod

Waiting for input

What you get

How each result is checked

  1. Step 1: Your YAML is parsed strictly as YAML 1.2: duplicate keys and syntax errors are rejected with the line number.
  2. Step 1: The JSON output is parsed back and compared with the parsed YAML, value by value.
  3. Step 2: The generated code is run with Zod 4.
  4. Step 2: Your JSON is parsed with the generated schema. It must pass.
  5. Step 2: The schema agrees with a reference JSON Schema validator (Ajv) on a set of valid and broken test values.

What can't convert exactly

  • Anchors (&), aliases (*) and merge keys (<<) are expanded into full copies, because JSON has no references.
  • Comments and custom tags such as !Ref are not data, so they are not carried over. You get a warning when this happens.
  • Several documents separated by --- become one JSON array.
  • The schema describes what the sample shows: whole numbers become integers, and keys present in every record are required. Review it before using it for strict validation.
  • Format checks (email, date-time…) are off by default, so a sample value that only looks like an email does not make the field stricter than intended.

Questions

How is a two-step conversion checked?

Your input is converted to JSON first, then to the target format. Each step has its own independent check, and both must pass. The checks of both steps are listed under every result.

Is my data uploaded?

No. Everything runs in your browser, in a background worker. Nothing is sent to a server.

How do I convert YAML to Zod online?

Paste your YAML or open a file on the left (or click Example). The Zod appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.

Can the Zod output be wrong?

Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.