YAMLSchema

JSON Schema

Roundtrip diff


  

Editor settings

Scroll source
Current Schema follows the most recently focused editable pane.
Clear all site data, cookies, consent, and shared editor content, then reload the default demo.

Using the YAMLSchema editor

This editor converts between YAMLSchema and JSON Schema so you can work in either format and see the equivalent representation beside it. It also verifies that the source roundtrips to the other format and back without losing information. When the schema file doesn't roundtrip, a diff is available to show where the information was lost.

Choose a starting schema

The left menu contains YAMLSchema examples and the right menu contains JSON Schema examples. Choosing either one makes that pane the source and generates the other representation. The URL changes to a shareable schema link.

Edit and convert

Edit .ysd in the left pane or JSON Schema in the right pane. JSON Schema may be written as JSON or YAML, and the editor detects the serialization automatically. Conversion happens automatically after you stop typing and runs entirely in this browser. Generated panes display a short message while conversion is active.

Select .ysdc to inspect the canonical YAMLSchema representation. .ysdc is generated and read-only, so switch back to .ysd to edit the YAMLSchema source.

Strict becomes available after editable JSON Schema successfully generates YAMLSchema. Select it to close every unconstrained mapping in the YAMLSchema and regenerate the JSON Schema with `additionalProperties: false` where needed. Strict removes `.open` directives and suppresses open-map forms such as `+Map{}` and `+Str: +Any`, while preserving typed wildcard rules such as `+Str: +Str`. Once applied, Strict remains checked and cannot be undone in the UI. Editing the JSON Schema clears Strict; it becomes available again after the edited schema successfully generates YAMLSchema. The control is disabled when YAMLSchema is the source.

Generated JSON Schema is marked Normal. Editing the JSON Schema clears that mark. Select Normal to replace edited JSON Schema with its normalized, canonical form and regenerate YAMLSchema. Normal and Strict regeneration preserve whether the JSON Schema is written as JSON or YAML.

Share content and lines

Edited source content is compressed into the URL so the current schema can be shared without sending it to a server. Select a line number to highlight that line in the shared link. Shift-select another line number to extend the highlighted range. Opening the shared link scrolls the selected range to the top of its pane. Select in the editor or press Escape to clear the line highlight.

Adjust editor settings

Scroll sync keeps one pane aligned while its selected source pane scrolls. YAMLSchema always uses the left pane as the scroll source. JSON Schema always uses the right pane. Current Schema follows the most recently focused editable pane, which is also the pane with the roundtrip indicator. You can turn scroll sync off when comparing different sections. The scroll source choice is saved between visits. JSON Schema loaded as YAML stays in YAML when regenerated from YAMLSchema. Format JSON as YAML forces JSON content in both panes to use YAML syntax and disables .ysdc as JSON while selected. Otherwise, settings can show generated .ysdc content as JSON instead of YAML. Factory Reset immediately clears all site settings, examples, shared editor content, cookies, and consent, then reloads the default demo.

How roundtrip checking works

A roundtrip starts with the current source pane and passes the schema through the other format before converting it back. Choosing an example or editing a pane makes that pane the source. Focusing an editable pane also makes it the source and starts a new check. Generated .ysdc is read-only and is not used as a source.

For YAMLSchema source, the editor:

  1. Expands .ysd into canonical .ysdc.
  2. Converts the schema to normalized JSON Schema.
  3. Converts that JSON Schema back to canonical .ysdc.
  4. Compares the original and regenerated .ysdc documents.

For JSON Schema source, the editor:

  1. Parses the source as JSON or YAML.
  2. Normalizes it as draft 2020-12 JSON Schema.
  3. Converts the normalized schema to .ysd.
  4. Converts that .ysd back to normalized JSON Schema.
  5. Compares the original and regenerated normalized schemas.

Comparing canonical forms ignores presentation differences such as JSON versus YAML serialization, indentation, and compact versus expanded YAMLSchema syntax. It checks whether the supported schema meaning survives conversion.

When the comparison fails, select the X indicator to view a unified diff between the canonical original and the canonical roundtrip. Red lines were lost or changed, and green lines were introduced by the conversion.

Understand roundtrip status

  • means the roundtrip is being checked.
  • means the supported meaning survived.
  • X means it changed. Select the X to inspect a unified diff.
  • ? means the source could not be parsed or converted.

The indicator appears only beside the current source pane. Focusing an editable pane also starts a fresh roundtrip check.

Edits are stored only in the current URL. Reloading or sharing that URL restores the same source and highlighted lines.