To format JSON, XML or YAML online, paste it into a formatter, choose 2 or 4 spaces of indentation and click Format. The tool parses the data first, so if anything is broken it points to the exact line and column. Once it's valid, you can also convert it: JSON to CSV for a spreadsheet, XML to JSON for an API, or YAML to JSON for a script.
Tools used in this guide
All free, with no sign-up. They run in your browser.
JSON vs XML vs YAML at a glance
All three formats store structured data: values, lists and nested groups. They differ in how strict and how readable they are.
| JSON | XML | YAML | |
|---|---|---|---|
| Looks like | {"name": "Asha"} | <name>Asha</name> | name: Asha |
| Structure from | Braces and brackets | Opening and closing tags | Indentation |
| Comments | Not allowed | <!-- like this --> | # like this |
| Data types | String, number, true/false, null, array, object | Everything is text unless a schema says otherwise | Strings, numbers, booleans, null, lists, maps (guessed from the value) |
| Attributes / metadata | No | Yes (<total currency="INR">) | No |
| Strictness | Very strict, easy to parse | Strict, verbose | Forgiving to write, easy to get subtly wrong |
| Typical use | Web APIs, app settings, package.json | Sitemaps, RSS, SOAP, Office files, invoices and bank feeds | Docker Compose, Kubernetes, GitHub Actions, CI config |
Here is the same small record in all three:
{ "order": { "id": 1001, "customer": "Asha Verma", "paid": true, "items": ["kurta", "dupatta"] } }
<order id="1001">
<customer>Asha Verma</customer>
<paid>true</paid>
<items><item>kurta</item><item>dupatta</item></items>
</order>
order:
id: 1001
customer: Asha Verma
paid: true
items:
- kurta
- dupatta
How to format and validate each format
JSON
Paste your data into the JSON formatter, or upload a .json file. Then:
- Click Validate to check the syntax. Valid JSON gets a green message; broken JSON gets a plain-language error with its line and column.
- Click Format to pretty-print it with 2 or 4 spaces.
- Click Minify when you need the smallest version, for example to paste into an environment variable.
- If validation fails, try Auto-fix. It repairs the three most common problems — trailing commas, single quotes and unquoted keys — and wraps several separate objects into one array.
- Copy the result or download it as
formatted.json.
XML
The XML formatter works the same way. Validate checks that the document is well-formed: every tag closed, properly nested, one root element. Format indents it, Minify strips the whitespace between tags, and Tree view shows the structure as a collapsible outline, which helps with deeply nested feeds. It can also turn the XML into JSON in one click.
Note: "Well-formed" and "valid" are different in XML. Well-formed means the syntax is correct. Valid means it also matches a schema (XSD or DTD) that defines which tags are allowed. Online formatters check the first; schema validation needs the schema file.
YAML
YAML has no braces to count, so mistakes are easy to miss by eye. The quickest check is to run it through the YAML to JSON converter. If the YAML is broken, you get the line and column of the problem. If it converts, read the JSON output: it shows exactly how the parser understood each value, which catches type surprises (more on those below).
Common syntax errors and how to fix them
JSON errors
| Error | Broken | Fixed |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Asha'} | {"name": "Asha"} |
| Unquoted key | {name: "Asha"} | {"name": "Asha"} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Comments | {"a": 1} // note | Remove the comment |
| Not-a-value | {"total": NaN} or undefined | Use null or a number |
| Unescaped quote in text | "He said "hi"" | "He said \"hi\"" |
Browser error messages can be cryptic. "Expected double-quoted property name" usually means a trailing comma just before a }. "Expected ',' or '}' after property value" means a missing comma. The column number marks where the parser gave up, which is usually just after the real mistake, so look a little to the left of it.
XML errors
- Tag not closed or wrongly nested:
<a><b>x</a>— close the inner tag first:<a><b>x</b></a>. - Case mismatch:
<Item>x</item>— XML is case-sensitive, so both tags must match exactly. - Bare ampersand or less-than sign:
<name>Fish & Chips</name>— write&and<, or wrap the text in<![CDATA[ … ]]>. - Unquoted attribute:
<order id=1001>— attributes always need quotes:id="1001". - More than one root element: wrap everything in a single parent such as
<orders> … </orders>. - Text before the declaration:
<?xml version="1.0"?>must be the very first thing in the file, with no blank line or space before it.
YAML errors
- Tabs for indentation. YAML forbids tabs. Replace them with spaces (2 is the convention) and set your editor to insert spaces.
- Inconsistent indentation. A key indented one space more than its siblings becomes a nested child, or an error. Keep each level at the same depth.
- No space after the colon.
name:valueis read as one string, not a key and value. Writename: value. - A colon inside a value.
title: Error: not foundbreaks. Quote it:title: "Error: not found".
YAML also guesses types, and the guesses can surprise you. Our converter reads YAML 1.2, and running it shows these real results:
| You wrote | Parsed as | Fix |
|---|---|---|
version: 1.10 | 1.1 (a number) | version: "1.10" |
zip: 01234 | 1234 (leading zero lost) | zip: "01234" |
enabled: yes | "yes" (text) in YAML 1.2, but true in older YAML 1.1 parsers such as PyYAML | Use true / false |
country: NO | "NO" in YAML 1.2, but false in YAML 1.1 parsers | country: "NO" |
Tip: When in doubt, quote it. Quoted values are always strings in every YAML parser.
Converting between JSON, XML, YAML and CSV
JSON to CSV or Excel (for spreadsheets)
The JSON to CSV converter turns an array of objects into rows. Each key becomes a column, and any value containing a comma or quote is wrapped in quotes so it stays in one cell.
[
{ "id": 1, "name": "Asha", "city": "Pune", "plan": "Pro" },
{ "id": 2, "name": "Rahul", "city": "Kochi", "plan": "Free" },
{ "id": 3, "name": "Meera, R.", "city": "Delhi", "plan": "Pro" }
]
becomes:
id,name,city,plan
1,Asha,Pune,Pro
2,Rahul,Kochi,Free
3,"Meera, R.",Delhi,Pro
CSV is a flat table, so it works best with flat records. If your objects contain nested objects or lists, use JSON to Excel instead. It flattens nested fields into dotted column names and downloads a real .xlsx file. For example, {"id": 1, "address": {"city": "Pune", "pin": "411001"}, "tags": ["new", "vip"]} becomes the columns id, address.city, address.pin, tags.0 and tags.1.
XML to JSON (for APIs and scripts)
The XML to JSON converter follows three simple rules. Attributes become keys starting with @. An element's own text, when it also has attributes, becomes #text. Repeated elements become an array, and numbers and booleans in element text are typed.
<orders>
<order id="1001" status="paid">
<customer>Asha Verma</customer>
<total currency="INR">2499</total>
</order>
<order id="1002" status="pending">
<customer>Rahul Nair</customer>
<total currency="INR">799</total>
</order>
</orders>
becomes:
{
"orders": {
"order": [
{ "@id": "1001", "@status": "paid", "customer": "Asha Verma",
"total": { "@currency": "INR", "#text": 2499 } },
{ "@id": "1002", "@status": "pending", "customer": "Rahul Nair",
"total": { "@currency": "INR", "#text": 799 } }
]
}
}
Warning: A single
<order>becomes an object, but two or more become an array. If your code always expects an array, handle the one-item case too.
YAML to JSON (for tools that only read JSON)
YAML to JSON is useful when a script, API or validator only accepts JSON. It also shows how a config file is really being read.
app:
name: invoice-api
port: 8080
debug: false
allowed_origins:
- https://example.com
- https://admin.example.com
version: 1.10
becomes:
{
"app": {
"name": "invoice-api",
"port": 8080,
"debug": false,
"allowed_origins": ["https://example.com", "https://admin.example.com"],
"version": 1.1
}
}
Notice the last line: 1.10 turned into 1.1. That's the type-guessing problem from the table above, caught before it reached production. The same converter works in reverse (JSON to YAML), and a file with several YAML documents separated by --- becomes a JSON array.
Keep your data private: why browser tools matter
Config files and API responses often contain things you shouldn't paste into a random website: API keys, customer names, phone numbers, internal hostnames.
The formatters and converters on this site run in your browser. The JSON and XML formatters parse with your browser's own engine. The converters use JavaScript libraries loaded into the page. Either way, your data isn't sent to a server for processing. Even so, a few habits help:
- Remove secrets before pasting anywhere, and rotate any key you've accidentally shared.
- Use sample data when asking for help on a forum or in a chat.
- Check what a tool does with your input. If a site uploads your file to a server, assume it's stored somewhere.
Bookmark the two formatters, and keep the converters for the moments when one system speaks a different format from the next.