JSON / YAML Formatter
Format, validate, and beautify JSON & YAML
About JSON / YAML Formatter
Format, validate, and beautify JSON & YAML
Watch: JSON / YAML Formatter in Action
- What's the fastest way to debug a messy API response?
- Paste it here first to format and validate it — turning a wall of minified text into properly indented, readable JSON is usually the fastest way to actually spot what's wrong with the data.
- Does it convert JSON to YAML and back?
- Yes. The third button reads JSON to YAML for JSON input and YAML to JSON for YAML input. Pressing Format on YAML input also gives JSON. Indent and Sort keys apply to the conversion as well.
- What does Fix it for me repair?
- Text-level problems only: comments, single-quoted strings, unquoted keys and trailing commas. It then re-checks the result, and if the text is still not valid JSON the button does not appear. It replaces the Input text with the repaired version.
- Will large numbers or values like 1.10 be changed?
- Not when formatting or minifying JSON; they are kept exactly as typed. In a YAML conversion, large whole numbers are kept but decimals become ordinary numbers, so 1.10 turns into 1.1.
- How does it decide that my input is YAML?
- Text starting with a bracket, brace or quote is treated as JSON. Otherwise it tries JSON first, then YAML, and calls it YAML only if the YAML parses into an object or list. The label above the box shows the result.
- What does Sort keys do exactly?
- It orders object keys alphabetically at every nesting level in the output. The order of items inside arrays is not touched. It works with Format, Minify and the conversion button.
How to use JSON / YAML Formatter
Paste JSON or YAML into the Input box, or choose Upload file for a .json, .yaml, .yml or .txt file. The label shows whether the text was detected as JSON or YAML. Pick an Indent of 2 spaces, 4 spaces or Tab, and tick Sort keys if you want object keys ordered alphabetically at every level.
Then press a button. Format / Beautify pretty-prints, Minify compacts to one line, and the third button reads JSON to YAML or YAML to JSON depending on what was detected. The Output box has Text and Tree views for JSON results, plus Copy and Download, which saves output.json or output.yaml.
If parsing fails, a red message gives the reason and, when available, the line and column with a caret under the spot. A Fix it for me button appears when the problem looks repairable.
When to use it
Use it when an API response arrives as one unreadable line, when a config file will not load and you need the exact position of the typo, or when you must switch a small config between JSON and YAML. The Tree view, with its Expand all and Collapse all links, helps when you want to explore a deeply nested response rather than scroll through it.
When not to use it
It is not a schema validator: valid syntax does not mean the data matches what your application expects, so use a JSON Schema validator for that. It is also a poor fit for multi-megabyte logs or files holding several YAML documents, where a command line tool such as jq is more dependable. For data you query repeatedly, a path expression is faster than reading it.
Tips for best results
Press Fix it for me when an error points at a trailing comma, single quotes or comments; the repair also quotes bare keys, and it rewrites the Input box so you can see exactly what changed. Turn on Sort keys before comparing two payloads in a diff tool, since key order then stops creating noise. Minify followed by Copy gives a single-line value suited to an environment variable.
Limitations
Big integers and decimals like 1.10 stay exactly as written when you format or minify JSON, but converting to YAML, or reading YAML at all, turns decimals into ordinary numbers, so 1.10 becomes 1.1 and very long decimals can lose digits. Files with several YAML documents are rejected. Tab indent applies to JSON; YAML output always uses two spaces for it.
Privacy
Parsing uses the lossless-json and js-yaml libraries inside your browser tab, and uploaded files are read by the browser's file API on your device, so the data is not sent anywhere for processing. The Text and Tree outputs are built locally. When you press Format, Minify or the conversion button, the site logs the tool name and a device identifier, not your data.
More from Security & Developer: