YAML to JSON Converter
Turn any YAML document into clean, pretty-printed JSON. The parser understands nested mappings, sequences, inline flow collections, comments, quoted values and literal block scalars, so a Kubernetes manifest or a workflow file converts without losing the structure it was written in.
YAML input
JSON output
Ready — paste some input or load the sample.
100% Client-Side · Privacy First. This tool runs entirely inside your browser. Nothing you type is uploaded, logged or sent to a server — you can even use it offline.
Overview
YAML is a superset of JSON, but only in theory: in practice a YAML file is full of features that have no JSON equivalent, and a converter has to decide what to do with each of them. Comments disappear, because JSON has nowhere to put them. Anchors and aliases become duplicated values, because JSON has no references. Block scalars such as | and > become ordinary strings with their line breaks intact, which is the part that matters most for shell scripts and certificates embedded in a Kubernetes manifest. Sequences of sequences, nested mappings with inconsistent indentation, and values that look like booleans all need careful handling. This converter reads the document, resolves the block scalars properly so a multi-line script keeps every blank line and every comment character, unfolds the nested structures, and emits JSON that parses cleanly. It reports what it could not represent instead of silently dropping it.
How to use the yaml to json converter
- 1Paste your YAML into the input panel.
- 2Read the JSON in the output panel and check it against the original.
- 3Read the notes for anything that was approximated or that could not be represented.
- 4Copy the JSON into your code, your API body or a configuration file.
- 5Use the JSON to YAML converter to check the round trip when the exact shape matters.
- 6Read the notes for anything that was approximated, because a value that YAML treats as a string may arrive as a number.
Cheat sheet
The syntax you will use most, and what each part does.
| Pattern | What it means |
|---|---|
| |
A literal block scalar: the lines keep their newlines exactly as they were written. |
> |
A folded block scalar: the newlines become spaces, so the value reads as a paragraph. |
# comment |
Comments are removed, because JSON has no comment syntax. |
- 1
- 2 |
A sequence becomes a JSON array, and nested sequences become arrays of arrays. |
key: "value" |
Double quoted values are unquoted, and single quoted values lose the doubled single quotes. |
null or ~ |
Both become the JSON null value. |
Common mistakes
A multi-line script arrives as one line.
A folded scalar with the > marker is the cause. Use | for a literal block so the line breaks are preserved exactly.
A hash inside a value disappears.
A # that follows a space starts a comment. Quote the value to keep the hash as part of the data.
Indentation errors are reported.
YAML is indentation sensitive. A mapping that is indented inconsistently below its parent cannot be resolved, and the converter says so instead of guessing.
An alias has no value.
An anchor and its alias have no JSON equivalent. The referenced value is copied to each place that uses it.
Worked examples
A manifest with a script
job:
script: |
#!/bin/bash
echo one
echo two
A JSON string with the shebang, both echo lines and the blank line between them all intact.
Nested sequences
matrix: - [1, 2] - [3, 4]
An array of two arrays, each with two numbers.
Frequently asked questions
Is my YAML uploaded?
No. The document is parsed inside your browser, so a file that contains credentials or internal host names never leaves the tab.
What happens to comments and anchors?
Comments are dropped, because JSON has no syntax for them, and anchors are resolved to the value they point at. A comment that matters to a human has to be carried over into your documentation by hand.
Does it support multi-document files?
Only the first document is converted, and the notes say so. Split a multi-document file with the separator if you need to convert each part.
Why did my long number become a float?
JSON has a single number type, so a value that YAML reads as an integer or as a float becomes a JavaScript number. A value with more precision than a double can hold is a good candidate for a string.
Are the block scalars preserved?
Yes. A literal block keeps its blank lines, its indentation and every hash character, which matters for the shell scripts that live inside a Kubernetes job template.
How are the single and double quoted strings handled?
A double quoted value is read as a JSON string, so its escape sequences apply. A single quoted value is read literally, with two single quotes standing for one, exactly as YAML defines it.
What happens to an empty value?
A key with nothing after the colon becomes null, and an empty mapping or sequence becomes an empty object or an empty array rather than disappearing.
Can I convert a file with Windows line endings?
Yes. Carriage returns are stripped before the document is parsed, so a file that was edited on Windows converts the same way as one edited on Linux.
Why is my quoted number still a string?
Because you quoted it, and a quoted scalar is a string in YAML. That is the way to keep a zip code or a version string from being read as a number.
Can I convert a Kubernetes manifest with a multi-line script?
Yes, and the script survives intact. A literal block scalar keeps its blank lines and its indentation, which is exactly what a shell script inside a manifest needs.
What happens to a YAML file that uses tabs for indentation?
YAML forbids tabs for indentation, so the parser reports an indentation error rather than guessing. Replace the tabs with spaces and convert again.