Skip to main content

Free YAML to JSON Converter

Convert YAML to JSON and JSON to YAML in both directions. Paste in either format and get the converted output instantly — no server upload required.

Works offline once loaded
JSON output
Output will appear here…

Common uses

  • Convert YAML to JSON for Kubernetes ManifestsConvert Kubernetes YAML to JSON (or back) for tooling, validation scripts, or applying via the API directly.
  • Docker Compose YAML / JSON ConversionConvert docker-compose.yml to JSON for inspection, or back to YAML after programmatic edits.
  • CI/CD Pipeline Config ConversionConvert GitHub Actions, GitLab CI, CircleCI, and other pipeline configs between YAML and JSON formats.
  • App Configuration File ConversionConvert app config files between YAML and JSON — useful when switching frameworks or sharing configs across tools.
  • OpenAPI / Swagger Spec ConversionConvert OpenAPI 3.x or Swagger 2.0 API specifications between YAML and JSON. Both formats are valid and interchangeable.

How It Works

Both directions of conversion — YAML to JSON and JSON to YAML — run entirely in your browser using a hand-written parser and emitter built into the page, with no third-party YAML library and no server involved. The logic lives in a single TypeScript module (lib/yamljson.ts) that handles mappings, sequences, scalars, quoted strings, and inline comment stripping.

  1. 1
    Input is preprocessed line by line
    For YAML input, the parser splits the text into lines, strips inline comments (tracking quote state to avoid stripping # inside strings), measures indentation depth, and discards blank lines — building a structured list of tokens before any parsing begins.
  2. 2
    A recursive descent parser builds the data tree
    The parser walks the token list using indentation level to determine structure. It recognises sequence items (- value), mapping keys (key: value), and nested blocks. Scalars go through a typed coercion step that handles null, booleans, integers (rejecting leading-zero values like 007 to avoid silent data corruption), and floats — with an optional mode that keeps YAML 1.1 barewords like yes, no, on, and off as strings rather than converting them to booleans.
  3. 3
    Unsupported YAML features are flagged, not silently dropped
    Before emitting output, the tool scans for anchors (&name), aliases (*name), merge keys (<<:), block scalars (| and >), multi-document markers (---), and duplicate mapping keys. Any of these triggers a visible warning rather than producing subtly wrong JSON.
  4. 4
    JSON is serialised or YAML is emitted, then made available
    For YAML→JSON, the parsed value is passed to JSON.stringify with your chosen indentation (2 spaces, 4 spaces, tab, or minified). For JSON→YAML, a custom emitter walks the parsed JavaScript value and produces indented YAML, quoting string scalars only when necessary (e.g., values that contain :, #, or look like reserved words). Output appears instantly as you type and can be copied or downloaded.

Related Tools

Frequently Asked Questions