Polyatic YAML ⇄ JSON Converter

YAML ⇄ JSON Converter

Convert YAML to JSON and JSON back to YAML live, with key order preserved and clear parse errors. Nothing is uploaded.

YAML input
JSON indent

The indent control sets the output indentation. Key order is always preserved; comments are dropped when converting to JSON.

Output JSON


        

Runs entirely in your browser — your data never leaves your device. Parsing uses the vendored js-yaml library you can read in this page's source; the conversion sends nothing you type over the network (only an anonymous page-view is counted).

What this tool does

Paste YAML (or a JSON document) into the box on the left and the converted result appears on the right the instant you stop typing — there is no button to press. Switch the direction toggle to go the other way; when you flip it, the current output is loaded back as the input, so you can round-trip a config file and confirm it survives the trip. A live status line reports the top-level shape it parsed (an object with n keys, an array of n items) and the line count, and any parse problem is shown inline in red — with the line and column when the parser can pinpoint it — rather than throwing away your work.

YAML and JSON, and why they convert cleanly one way

JSON is a compact, strict data format with a tiny fixed set of types: objects, arrays, strings, numbers, booleans and null. YAML is a superset designed for humans to write by hand — the same data, but with indentation instead of braces, optional quotes, comments, and shortcuts for repeated or multi-line values. Because YAML 1.2 is a strict superset of JSON, every valid JSON document is already valid YAML, so this converter happily accepts JSON in either direction. The reverse does not hold: converting YAML to JSON has to discard the things JSON cannot express, which is exactly where people get surprised.

Worked example: a config in, JSON out

Take a short YAML file with a comment, a nested map, a list and a block scalar:

name: polyatic-tools   # a comment
version: 4.1.0
tags:
  - yaml
  - json
author:
  name: Ada Lovelace
ports: [80, 443]

With 2-space JSON indent that becomes:

{
  "name": "polyatic-tools",
  "version": "4.1.0",
  "tags": ["yaml", "json"],
  "author": { "name": "Ada Lovelace" },
  "ports": [80, 443]
}

Three things to notice. The # a comment is gone — JSON has no comments. The [80, 443] written in YAML's inline "flow" style produces the same array as the dashed block style would. And version: 4.1.0 stays the string "4.1.0", because 4.1.0 is not a valid number (two dots), whereas a bare 443 becomes the number 443.

The type traps worth knowing

YAML's convenience comes from guessing the type of unquoted values, and the rules changed between versions. This tool uses js-yaml's YAML 1.2 core schema, which is stricter and less surprising than the old 1.1 behaviour:

You writeYou getNote
true, falsebooleanOnly these two spellings
yes, no, on, offstringStrings in 1.2 (were booleans in 1.1)
null, ~, emptynullAll three mean null
007"007"Leading zero → stays a string
3.14, 42numberReal numeric literals
2026-07-09stringNot a timestamp by default

The classic gotcha is the "Norway problem": a list of country codes containing NO used to parse as false under YAML 1.1. Under the 1.2 core schema this tool uses, NO is a plain string, so that trap is gone — but if you are targeting a system that still uses 1.1 rules, quote such values to be safe. When you want any value forced to a string, wrap it in quotes in your YAML.

Multi-line strings, anchors and flow style

YAML has two block-scalar styles this converter reads correctly: the literal | keeps newlines, and the folded > joins wrapped lines into spaces — both collapse into ordinary JSON strings with \n where appropriate. Anchors and aliases (&name to mark a node and *name to reuse it) are expanded to full copies in the JSON, since JSON cannot reference shared nodes. Going from JSON to YAML, the output is written without anchors, with long lines left unwrapped so a URL or token is never broken across lines.

Where you will use it

  • Kubernetes and CI: Kubernetes manifests, GitHub Actions and GitLab pipelines are YAML, but many tools, validators and APIs speak JSON — convert to check a value or feed a JSON-only linter.
  • Config files: turn a hand-written config.yaml into the JSON your app actually loads, or pretty-print an API's JSON response as readable YAML to eyeball it.
  • Learning the mapping: paste something in and flip the toggle to see exactly how a YAML construct maps to JSON and back.

Honest limits

Comments never survive a trip through JSON — that is JSON's design, not a bug here, so keep your YAML as the source of truth if the comments matter. Converting YAML to JSON also expands anchors into duplicated data, which can enlarge a file that leaned heavily on aliases. Custom YAML tags beyond the standard set (for example framework-specific !!python/object tags) are rejected rather than silently mishandled, which is the safe default. Everything runs synchronously on your device, so a multi-megabyte document may briefly freeze the tab; nothing is uploaded, logged, or stored, and the page is gone from memory when you close it.