YAML ⇄ JSON Converter

Convert YAML to JSON or JSON to YAML instantly in your browser. Upload a file, see parse errors with line numbers, then copy or download the result.

By

Advertisement

Free YAML to JSON Converter (and JSON to YAML)

Paste YAML and get JSON, or flip the mode and paste JSON to get YAML. Conversion happens as you type, entirely in your browser — nothing is uploaded and nothing is stored. You can also load a file directly (.yml, .yaml, .txt, or .json), copy the output to the clipboard, or download it. A Load Sample button drops in a small working document in either direction if you just want to see the shape of the output.

When the input will not parse, the parser’s own error message is shown with the line and column, which is usually enough to find an inconsistent indent or a stray tab. When it does parse, a small summary reports whether the top level is an object or an array and how many keys or items it has — a quick sanity check that you converted the document you meant to.

Where This Gets Used

Almost every configuration format in modern infrastructure is one of these two. Kubernetes manifests, GitHub Actions workflows, Docker Compose files, Ansible playbooks, OpenAPI specifications, and CI pipeline definitions are YAML. APIs, log pipelines, package manifests, and most tooling that speaks over the wire are JSON. Converting between them comes up constantly:

  • Pasting a Kubernetes manifest into a tool or API that only accepts JSON.
  • Turning a JSON API response into readable YAML for a config file or documentation.
  • Checking that a hand-written YAML file parses to the structure you think it does — the fastest way to catch a wrongly indented block is to look at the JSON.
  • Converting an OpenAPI document between the two formats a generator supports.
  • Reformatting a dense one-line JSON blob into something a human can review in a pull request.

How to Use It

  1. Pick a direction — YAML to JSON, or JSON to YAML.
  2. Paste or upload. The file picker accepts the extensions appropriate to the current mode.
  3. Read the output. It updates as you edit the input. JSON is pretty-printed with two-space indentation; YAML is emitted with two-space indentation and lines folded at 120 characters.
  4. Check the structure summary to confirm the top-level type and the key or item count.
  5. Copy or download the result.

The Relationship Between the Two Formats

YAML 1.2 is formally a superset of JSON: every valid JSON document is also valid YAML, which is why you can paste JSON into a YAML file and it works. The reverse is not true, and the parts of YAML that JSON lacks are exactly the parts that need care in a conversion:

FeatureYAMLJSONWhat happens on conversion
Comments# to end of lineNoneSilently discarded — the biggest practical loss
Anchors and aliases&name / *nameNoneExpanded in place; the shared reference becomes duplicated data
Multiple documents--- separatorsOne value per documentRejected — convert one document at a time
Multi-line strings| literal, > foldedEscaped \nPreserved in meaning, not in style
Non-string keysAllowedStrings onlyCoerced to strings
TimestampsNative typeNoneEmitted as an ISO 8601 string
Trailing commasN/AIllegalA common cause of JSON parse errors

Comments are worth dwelling on. If you round-trip a heavily annotated Kubernetes manifest through JSON and back, every explanatory comment is gone and no error is raised. Convert a copy, not the file your team maintains.

Anchors and aliases behave the way most people want but not the way the source document said. Given:

defaults: &defaults
  retries: 3
staging:
  <<: *defaults

the alias is resolved and the values are written out in full at each use site. The output is correct; it is just no longer DRY, and editing one copy no longer changes the other.

Type Coercion: the Conversions That Bite

YAML infers types from unquoted scalars, and that inference is where silent data corruption comes from. The parser used here follows the YAML 1.2 core schema, which is stricter than the old 1.1 behaviour but still has sharp edges. Some real results:

YAML inputJSON outputNote
zip: 02134"zip": 2134Leading zeros are lost — the classic postcode and account-number bug
version: 1.20"version": 1.2Trailing zero gone; a version string became a number
id: 1234567890123456789012345678901234567000Beyond the safe integer range for a double, precision is lost
count: 1_0001000Underscore digit separators are accepted
date: 2026-08-12"2026-08-12T00:00:00.000Z"Parsed as a timestamp, emitted as ISO 8601 in UTC
value: ~null~, null, and an empty value are all null

The fix in every case is the same: quote it. zip: "02134" stays a string, version: "1.20" stays a string, id: "12345678901234567890" keeps every digit. If a value is an identifier rather than a quantity you intend to do arithmetic on, quote it as a matter of habit.

One historical hazard that does not apply here is worth mentioning because so much advice still warns about it. Under YAML 1.1, unquoted no, yes, on, and off were booleans, which is how the country code for Norway famously became false. The 1.2 core schema recognises only true and false (in any capitalisation), so country: no converts here to the string "no". Other parsers in your pipeline may still use 1.1 rules, so quoting remains the safe habit — but this converter will not do that to you.

Duplicate keys are rejected rather than silently overwritten. x: 1 followed by x: 2 produces a parse error naming the line, which is a feature: in a long manifest, a duplicated key where the second quietly wins is a genuinely hard bug to find by eye.

Reading Parse Errors

YAML errors almost always come from one of a handful of causes:

  • Tabs. YAML forbids tab characters for indentation outright. If an editor inserted one, the message will point at a line that looks perfectly fine.
  • Inconsistent indentation. Sibling keys must line up in the same column. Two spaces here and three there is a structural change, not a formatting preference.
  • A missing space after a colon. key:value is a single scalar; key: value is a mapping.
  • An unquoted string starting with a special character — *, &, @, %, {, [, or a leading - followed by a space — which the parser reads as syntax.
  • A colon inside an unquoted value, such as a bare URL or a Windows path, which looks like a nested mapping.

JSON errors are narrower and usually one of: a trailing comma before } or ], single quotes instead of double quotes, unquoted keys, a comment (JSON has none), or curly “smart” quotes pasted from a document. The reported position is generally accurate; look just before it.

Output Formatting

JSON output uses two-space indentation, which is what most linters and diff tools expect. YAML output uses two-space indentation, folds long lines at 120 characters, and expands aliases rather than emitting anchors. That last choice means the YAML you get back is always self-contained — useful when it is going somewhere that may not resolve references, and something to be aware of if you were relying on the anchor for maintainability.

Long single-line strings are emitted in folded block style (>-) rather than as one very long line. The parsed value is identical; only the presentation differs.

Related Tools

For JSON alone, the JSON formatter and validator handles pretty-printing, minifying, and validating. The CSV to JSON converter covers tabular data. If the YAML in question is a Kubernetes workload definition, the Kubernetes manifest validator checks it against the schema and flags security issues, and the Dockerfile generator produces the image those manifests will run.

Frequently Asked Questions

Is my data uploaded anywhere?+

No. Parsing and serialisation both run in your browser. Files you select are read locally and never leave the machine, which makes the tool safe for configuration containing internal hostnames or infrastructure detail.

Are comments preserved when I convert YAML to JSON?+

No, and they cannot be — JSON has no comment syntax. They are discarded without warning. Round-tripping an annotated file through JSON and back will strip every comment, so work on a copy.

Why did my leading zeros disappear?+

An unquoted 02134 is parsed as the number 2134. Quote any value that is an identifier rather than a quantity: "02134". The same applies to version strings such as 1.20, which otherwise becomes the number 1.2.

Does this convert multi-document YAML files?+

No. Files containing several documents separated by --- produce an error saying a single document was expected. Split them and convert each in turn, or wrap them in a JSON array manually afterwards.

What happens to anchors and aliases?+

They are resolved and the referenced values are written out in full wherever they were used. The data is correct but no longer shares a single definition.

Does unquoted “no” become false?+

Not here. This converter follows the YAML 1.2 core schema, in which only true and false are booleans, so no stays the string "no". Older 1.1 parsers elsewhere in your toolchain may still coerce it, so quoting remains a sensible habit.

What happens to duplicate keys?+

Conversion fails with an error naming the line, rather than silently keeping the last value. That is intentional — a duplicated key in a long file is a bug worth surfacing.

How large a file can I convert?+

There is no hard limit, but everything runs on the browser’s main thread, so multi-megabyte documents can make the page pause while parsing. For very large files a command-line tool is a better fit.

Why is my JSON invalid when it looks fine?+

The usual suspects are a trailing comma, single quotes instead of double quotes, unquoted keys, or curly quotes pasted from a word processor. The error message gives a position — look immediately before it.

Can I control the indentation of the output?+

Not currently; both formats are emitted with two-space indentation, which matches the prevailing convention for Kubernetes, GitHub Actions, and most linters. Reindent afterwards if your project uses a different style.

Related tools

This tool is provided for informational and educational purposes only. While we strive for accuracy, we make no warranties about the completeness or reliability of results.