YAML to JSON Converter - Free & Private
Paste a YAML document and read it back as JSON. Nested maps, sequences, inline flow style, comments and block scalars are all handled in your browser.
Not supported: anchors, aliases and merge keys. A document containing &name, *name or <<: is rejected with a line number instead of being silently flattened.
Reading YAML configuration back as JSON
Paste a YAML file here and the parser rebuilds it as a JSON value tree. Indentation based maps and sequences, inline flow collections written with square brackets or braces, single and double quoted scalars, comments at the end of a line, and literal or folded block scalars are all recognised. Line endings can be Unix or Windows style, tabs used for indentation are rejected with the line number, and the output can be pretty printed or squeezed onto one line.
Backend developers hit this every time a service reads YAML but a debugging tool speaks JSON. Docker Compose files, OpenAPI descriptions, GitLab pipeline definitions and Ansible inventories all need to become JSON before you can push them through a schema validator, feed them to a REST endpoint, or query them with a JSONPath expression. QA engineers use the same route to turn fixture files into request bodies for an automated test suite.
What the parser deliberately refuses is just as important as what it accepts. Anchors, aliases and merge keys let one YAML block reuse another, and expanding them correctly requires resolving a graph rather than a tree. Instead of guessing and quietly producing a JSON document missing half its data, the tool stops and points at the line holding the ampersand, the asterisk or the merge key so that you know exactly what to flatten before trying again.
Type inference follows the YAML 1.2 core rules, which is the part most people get bitten by. Only the words true and false become booleans, so a value such as yes or off stays a string, and a version number written as 2.10 becomes the number 2.1 unless you quote it. Integers beyond the safe range of JavaScript are kept as strings so no digits are lost. Null is written as null, the tilde, or an empty value after the colon.
Comments disappear during conversion because JSON has no place to put them, which is the one detail worth remembering before you overwrite a source file. If you need to go the other way, the JSON to YAML Converter on ToolForte rebuilds indentation and quoting from a JSON document, and the JSON Formatter is the quickest way to inspect a large result once you have it.
How the YAML to JSON Converter Works
- 01Drop a .yaml or .yml file onto the input area, or paste the document straight from your editor.
- 02The parser walks the file line by line, tracking indentation to rebuild maps and sequences, and reading inline flow collections, quoted scalars and block scalars along the way.
- 03Pick pretty printed output with two or four spaces, or minified output when you need a compact payload.
- 04Copy the JSON or save it as a .json file. If the document cannot be read you get the exact line number instead of a partial result.
What the parser accepts and where it draws the line
Indentation based mappings and sequences form the backbone of almost every real YAML file, and both are supported to any depth, including sequences of mappings where the first key sits on the same line as the dash. Inline flow style written with square brackets or braces is parsed with a separate reader, so a compact list of ports or a one line resource limit block behaves exactly as it would in a full YAML implementation. Single and double quoted scalars are unescaped properly, with doubled single quotes collapsing to one and backslash escapes in double quoted text resolved. Literal and folded block scalars are read with their chomping indicators, so a trailing newline is kept, clipped or stripped as the document asks. Comments are stripped wherever they appear outside quotes. What is deliberately out of scope is the anchor and alias system, together with merge keys. Resolving those correctly means treating the document as a graph rather than a tree, and a converter that silently ignored them would hand you JSON missing entire blocks of configuration. Instead the parser stops at the line holding the ampersand, the asterisk or the merge key and tells you what to expand. Tabs used for indentation and multi document files separated by three hyphens are rejected the same way, with a line number.
When to Use the YAML to JSON Converter
Use it whenever something downstream refuses YAML. JSON Schema validators, REST clients, JSONPath queries, browser devtools and most scripting one liners all expect JSON, while the file you actually have is a Docker Compose service, an OpenAPI description, a GitLab pipeline or an Ansible inventory. It is also handy for inspection: converting a config to JSON flattens away the ambiguity of unquoted scalars, so you can see at a glance whether a value the application reads as a string was really parsed as a number.
Common Use Cases
- Feeding a Docker Compose or Kubernetes file into a JSON Schema validator before a deploy.
- Turning an OpenAPI description written in YAML into the JSON form a code generator expects.
- Converting fixture files into request bodies for an automated API test.
- Pretty printing or collapsing the JSON you get back JSON Formatter & Validator - Instant Results
- Going the other way once you have edited the data YAML ↔ JSON Converter - Instant & Free
Expert Tips
- If a number loses precision, quote it in the YAML. Integers larger than the safe range of JavaScript are kept as strings so no digits are lost, but a long decimal will still be rounded.
- An error pointing at a line that looks fine usually means the problem is on the line above it, most often a key whose value is missing or a list item indented one space too far.
- Minified output is the right choice when you are pasting into a curl command or an environment variable, because a pretty printed payload will pick up shell quoting problems.
Frequently Asked Questions
- An anchor marks a node so that an alias elsewhere can reuse it, and a merge key folds one mapping into another. Skipping them would produce JSON that looks complete but is missing data, which is far more dangerous than an error. Expand them in your editor or with a full YAML processor first, then convert the flattened document.
- No, it follows the YAML 1.2 core schema, where only true and false are booleans. Older parsers built on YAML 1.1 also treat yes, no, on and off as booleans, which is a well known source of surprises. If you want a boolean, write true or false in the source.
- They are dropped, because JSON has no syntax for comments. Keep the YAML file as the version you edit and treat the JSON as a generated artefact, otherwise the documentation in your config disappears the first time somebody converts back.
- Not in one pass. A leading separator at the top of a file is accepted and ignored, but a second one raises an error with its line number so that nothing gets merged by accident. Split the file and convert each document on its own.
Why are anchors and aliases rejected instead of ignored?→
My value yes came out as a string, not true. Is that a bug?→
What happens to my comments?→
Can it handle a file with several documents separated by three hyphens?→
Related tools
12 suggested- 01TSV to CSV Converter - Free & PrivateConvert tab separated data to RFC 4180 CSV with proper quoting, a semicolon option for Excel and a UTF-8 BOM toggle. Free and fully browser based.
- 02CSV to Markdown Table Converter - Free & PrivateConvert CSV to a Markdown table with per column alignment and RFC 4180 quoted field support. Free, browser based, nothing is uploaded to a server.
- 03XML to JSON Converter - Free & PrivateConvert XML and SOAP responses to JSON in your browser. Configurable attribute prefix, namespace handling and arrays for repeated tags. Free and private.
- 04JSON to YAML Converter - Free & PrivateConvert JSON to YAML in your browser with correct indentation, smart quoting and block scalars for multi line text. Free, private, nothing uploaded.
- 05HTTP Headers Checker - Free Response ViewerSee the status code, redirect chain and every response header for any URL, plus a free pass or fail audit of the six key security headers. No signup.
- 06DNS Lookup - A, MX, TXT, NS & MoreQuery A, AAAA, MX, TXT, NS, CNAME, SOA, and CAA records for any domain via DNS-over-HTTPS. Free browser-based DNS lookup with a query-all mode.
- 07ZIP Extractor - Open ZIP Files OnlineOpen and extract ZIP files directly in your browser: list contents, preview text and images, download files. Free and private - nothing is uploaded.
- 08User Agent Parser - Browser & OS LookupParse any user agent string to identify browser, version, engine, OS, and device type, including bots. Free, instant, and fully browser-based.
- 09HTML to JSX Converter - Free & InstantConvert HTML to valid React JSX instantly: className, camelCase attributes, style objects, and self-closed tags. Free, browser-based, and private.
- 10.htaccess Redirect Generator - Apache & NginxGenerate 301 and 302 redirect rules for Apache .htaccess and Nginx, with HTTPS, www, and trailing-slash templates. Free and fully browser-based.
- 11Generate .env.example Files - Free & PrivatePaste a .env file and instantly get a .env.example with secret values stripped. Free, browser-based, and private - credentials never leave your device.
- 12JSON Formatter & Validator - Instant ResultsFormat, validate, and minify JSON with instant error highlighting. Pinpoints syntax errors. Free, private, browser-based.