Skip to content
trace·warrior
Encoding & Hashing

JSON / YAML Formatter

Free JSON formatter and validator with YAML conversion. Pretty-print or minify any JSON, validate it, and convert between JSON and YAML in either direction. Also a JSON beautifier and YAML formatter for engineers who need both in one place.

Input
Output

Format, minify, and validate JSON

Pretty-printing re-indents JSON so its nesting is readable, and minifying strips every space and newline to shrink a payload for transport. Both change only whitespace, except that integers larger than 2^53 are rounded by JavaScript (the tool warns you when that happens). Validation is the useful part, because JSON is strict. Keys must be double-quoted, strings cannot use single quotes, trailing commas are not allowed, and comments are not part of the format. This tool reports the exact point where parsing fails so you can find a stray comma or an unquoted key quickly.

Everything runs in your browser, so you can paste config, an API response, or a log line without sending it anywhere. Use the pretty-print view to inspect an unfamiliar response and the minify view to produce a compact string for a query parameter or an environment variable.

Converting between JSON and YAML

YAML is a near-superset of JSON aimed at human editing: it uses indentation instead of braces, allows comments with #, and can reuse values with anchors and aliases. Because valid JSON is also valid YAML, converting JSON to YAML is straightforward, and this tool goes both directions so you can move config between a service that wants JSON and one that wants YAML.

Watch two gotchas when converting. Comments and anchors have no equivalent in JSON, so they are lost on the way from YAML to JSON. And YAML is whitespace-sensitive: a value like on, no, or a leading-zero number can be read as a boolean or a different type unless it is quoted, which is a classic source of surprising config bugs. This tool reads YAML with the YAML 1.2 core schema, so dates and words like on stay plain strings, but many YAML 1.1 parsers still in use do convert them.

Frequently asked questions

What is the difference between JSON and YAML?

JSON uses braces and brackets and is strict about quoting and commas, which makes it ideal for machines and APIs. YAML uses indentation, allows comments, and is easier to hand-edit. Most valid JSON is also valid YAML, so the two convert cleanly.

How do I validate JSON?

Paste it into the tool and it parses the text with a strict JSON parser. If the syntax is valid it formats the output; if not, it reports where parsing failed so you can fix the offending character.

Is YAML a superset of JSON?

In practice yes. YAML 1.2 was designed so that any valid JSON document is also valid YAML, which is why JSON can be dropped straight into a YAML file and why converting JSON to YAML is lossless.

Why does my JSON fail to parse?

The usual causes are trailing commas after the last item, single quotes instead of double quotes, unquoted keys, or comments, none of which JSON allows. The tool points to the position of the error so you can correct it.

Related tools