About the YAML to JSON Converter
Configuration lives in both formats: YAML is pleasant to write but strict about indentation, while JSON is verbose but completely unambiguous. This tool converts YAML to JSON and back, handling maps, sequences, nesting, comments and multi-line text blocks, and reports the line of any indentation or syntax error. It is a daily task for anyone working with CI pipelines, Docker and Kubernetes files or application settings, and converting to JSON is also a quick way to see exactly how a YAML file will be read. Some values surprise people, such as unquoted yes or no in older YAML versions, so check the JSON output when values look wrong. For formatting the result, use the JSON Formatter, and for XML, the JSON to XML Converter.
The parser understands the YAML found in everyday configuration: maps and lists nested inside each other, quoted and plain values, multi-line text written with the | or > markers, inline collections in square or curly brackets, comments, several documents in one file separated by three dashes, and the usual value types such as booleans, nulls, whole numbers and decimals.
A handful of advanced YAML features fall outside what the tool supports, notably references between parts of a document, merging maps with << and custom type tags; the full specification is much larger than the subset most files use. When a file uses one of them, the tool says so plainly instead of guessing, so you never receive output that looks right but quietly means something different.
How to use the YAML to JSON Converter
- Pick the directionConvert YAML into JSON, or JSON into YAML.
- Paste the contentA configuration file, a deployment manifest or an API response.
- Run ConvertThe converted text appears, or a message pointing to the line that failed.
- Save the resultCopy it or download the converted file.
YAML to JSON Converter features
- Conversion from YAML to JSON and from JSON to YAML
- Maps and lists nested to any depth
- Multi-line text in literal and folded styles
- Inline collections written with brackets
- Comments recognised and kept wherever the target format allows
- Several documents in one file split at three dashes
- Errors that name the line and describe the fault
- Unsupported features flagged instead of misread
Common uses
- Viewing a CI pipeline file as JSON to see its true structure
- Making a JSON API response easier to read as YAML
- Checking the indentation of a Kubernetes or Docker Compose file
- Moving settings between tools that expect different formats
- Finding the exact line where a YAML file breaks
YAML to JSON in practice: CI files, version numbers that change, port mappings, block text and validation
YAML runs much of modern software: build pipelines, container files, server configuration and deployment manifests. Its friendly syntax hides rules that change values without warning, and converting YAML to JSON is the quickest way to see exactly what a parser understands. This guide works through a container configuration, explains values that YAML quietly reinterprets, covers multi-line text and several documents in one file, and shows how conversion helps with validation.
A worked example: a container configuration
A small container file describes one web service:
services:web:image: nginx:1.27ports:- "8080:80"
Converted to JSON, it becomes an object with a services key, containing a web object with an image string and a ports array holding the string 8080:80. Seeing the structure written out with braces and brackets confirms that the indentation placed each key where it was intended, which is the most common source of confusion in YAML files.
Why port mappings are quoted
The quotes around 8080:80 are not decoration. Older YAML parsers following version 1.1 of the specification read unquoted values such as 22:22 as base-60 numbers, a leftover feature for writing times, so 22:22 becomes the number 1342. Container documentation recommends quoting port mappings for exactly this reason. Converting to JSON reveals the problem instantly, because the value appears as a number instead of a string.
Version numbers that change
In a build matrix, python-version: 3.10 looks harmless, but YAML reads 3.10 as a decimal number, which is exactly 3.1. The build then installs the wrong version, a mistake many developers have run into in pipeline files. Writing the value in quotes keeps it as the text 3.10. The same caution applies to any version number ending in zero.
Leading zeros
Postcodes, account codes and other identifiers that begin with zero are also at risk. An unquoted 01234 may be read as a number and lose its leading zero, and older parsers treat it as an octal number, turning it into 668. Quoting any value that is really an identifier rather than a quantity keeps it intact through conversion and back.
Multi-line text
Block scalars hold multi-line text such as scripts, certificates and messages. A block written with the pipe character keeps line breaks and adds a newline at the end of the text, while the variant written as pipe followed by a hyphen removes that final newline. The difference matters when a value such as a key or token is compared exactly. In the JSON output, line breaks appear as \n, so you can see precisely what the value contains.
Several documents in one file
Deployment files often contain several resources separated by three dashes, such as a service, a deployment and a configuration map in one file. Each part is a separate document. Converting shows each one as its own JSON object, which makes it easy to check that a resource has not accidentally merged with the next because a separator is missing.
Duplicate keys
The YAML specification requires keys to be unique, but many parsers quietly keep only the last value when a key appears twice, for example when a long file is edited by several people. Converting to JSON shows which value survived. If an earlier setting seems to be ignored, search the file for a second copy of the same key further down.
Validating configuration
Many tools validate configuration against a JSON Schema, a description of which keys and value types are allowed. Because YAML converts directly to JSON, the same schema checks both. Converting a file and validating the JSON catches misspelt keys and wrong types before a deployment fails at runtime, which is far cheaper than discovering them in production.
Common mistakes
- Leaving version numbers, ports and codes unquoted.
- Mixing indentation widths within the same file.
- Forgetting the three dashes between documents.
- Assuming a duplicated key raises an error.
Related tools
To tidy the JSON output, use JSON Formatter. To explore large configurations as a tree, try JSON Viewer, and to compare two versions of a configuration, JSON Diff.
JSON is already YAML
YAML version 1.2 was designed so that almost any JSON document is also valid YAML. Tools that read YAML configuration will usually accept JSON-style braces and brackets, which helps when configuration is generated by a program. Converting in the other direction, from YAML to JSON, is what makes the structure explicit and removes guesswork about indentation.
Placeholders and templating
Many deployment tools insert values into YAML through placeholders such as ${DB_HOST} before the file is used. To a YAML parser these are simply strings, so conversion shows them unchanged. If a converted value looks wrong, check whether a templating step runs before the configuration is read, because the final value is decided there rather than in the YAML itself.
Privacy
Conversion runs entirely in your browser. Configuration files, which often contain hostnames and settings, are not uploaded or stored. Remove passwords and keys before sharing converted output with anyone.
Frequently asked questions
Why do I get an indentation error?
YAML uses indentation to express structure and does not allow tab characters at all. One tab anywhere, or a line indented differently from the items around it, makes the file invalid, and the error message tells you which line to look at.
Which YAML features are missing?
Reusable references (the & and * syntax), the << merge key, application-specific tags and some uncommon constructs. Instead of guessing, the tool reports them, because silently misreading a configuration file is more dangerous than refusing to convert it.
How are yes and no treated?
Like true and false, they become boolean values, an old YAML habit that catches many people out, for example with country codes such as NO. If you need the actual word as text, put it in quotes.
What happens to comments when I convert to JSON?
They are lost, because JSON has no way to write comments. Turning the JSON into YAML again cannot recover them, so keep the original file if its comments document important settings.
Is the YAML produced from JSON valid?
Yes. Keys that need quotes get them, text that would otherwise be read as a number or boolean is quoted, and nested structures are indented consistently, so the result loads cleanly in standard YAML parsers.
Is my configuration uploaded anywhere?
No. Your browser does all the parsing, which matters for files that hold database hosts, tokens or passwords you would never hand to a third party.