JSON & XML Formatter & Validator
Paste messy code and get it beautified, validated or fixed in an instant. Find errors by line and column, convert JSON to XML and back, and explore your data as a tree.
Input JSON
Output Beautified JSON
{
"store": {
"name": "Demo Gadgets",
"open": true,
"rating": 4.8,
"location": {
"city": "Berlin",
"country": "DE"
}
},
"orders": [
{
"id": 1001,
"customer": "Anita Gurung",
"items": [
{
"sku": "KB-01",
"qty": 2,
"price": 29.99
},
{
"sku": "MS-07",
"qty": 1,
"price": 14.5
}
],
"paid": true,
"coupon": null
},
{
"id": 1002,
"customer": "Ravi Thapa",
"items": [
{
"sku": "HD-22",
"qty": 1,
"price": 89
}
],
"paid": false,
"coupon": "WELCOME10"
}
],
"updated": "2026-11-17T09:30:00Z"
}A JSON and XML toolkit that does the boring work for you
No signup, no ads in your way, no upload. Open the page, paste your code and work.
Beautify & pretty print
Turn one unreadable line into clean, indented code with 2 spaces, 4 spaces or tabs. Long XML tags wrap automatically.
Minify
Strip every extra space and line break to shrink payloads for APIs, configs and storage. See how much smaller it got.
Validate with exact errors
Get the precise line and column, a plain-English explanation and a code frame that points at the problem. Jump to it in one click.
Auto-fix broken JSON
Repairs comments, single quotes, unquoted keys, trailing and missing commas, True/None, undefined and more, and tells you what it changed.
Sort keys AβZ
Sort every object in your JSON alphabetically so two files are easy to compare and diffs stay small.
JSON β XML converter
Convert JSON to XML and XML to JSON in one click. Attributes, text, repeated elements and CDATA are handled.
Tree view
Explore large documents as a collapsible tree. Expand all, collapse all and see object and array sizes at a glance.
Private by design
Your code is processed in your browser. Nothing is uploaded to a server, and big numbers keep every digit.
Format and validate JSON in 3 steps
Paste or drop your code
Paste JSON or XML into the Input box, press the paste button, or drop a file. The type is detected for you.
Pick what you need
Beautify, Minify, Validate, Auto-fix, Sort keys or Convert. The result updates live as you type.
Copy or download
Copy the output, download it as a file, or send it back to the input to keep working on it.
The most common JSON errors and how to fix them
Most βinvalid JSONβ messages come from the same handful of mistakes.
| Problem | What it looks like | How to fix it |
|---|---|---|
| Trailing comma | A comma before } or ] | Remove the last comma, or use Auto-fix. |
| Single quotes | {'name': 'Alex'} | JSON needs double quotes: {"name": "Alex"}. |
| Unquoted keys | {name: "Alex"} | Wrap every property name in double quotes. |
| Missing comma | Two properties with nothing between them | Add a comma after the first value. |
| Comments | // note or /* note */ | JSON has no comments. Delete them, or use Auto-fix. |
| Raw line break in a string | A real new line inside "text" | Write it as \n inside the string. |
| undefined, NaN, True, None | Values copied from JavaScript or Python | Use null, true and false in lower case. |
| Leading zeros | 007 or 01 | Write 7 or 1. Or make it a string: "007". |
| Unclosed bracket | A { or [ that never ends | The error points to where it started. Add the missing } or ]. |
JSON vs XML: which one do you have?
JSON
Light, easy to read and the default format for web APIs and modern config files.
- Objects, arrays, strings, numbers, true, false and null
- No comments and no trailing commas
- Smaller than the same data in XML
XML
Tag-based and strict about structure. Common in feeds, SOAP services, office files and older systems.
- Elements, attributes, text, CDATA and comments
- One root element, and every tag must be closed
- Tag names are case-sensitive
JSON and XML formatter questions, answered
Is my data sent to a server?
No. The formatter, validator and converter run entirely in your browser, so the text you paste or the file you open is never uploaded. You can safely use it with private configs, but never share secrets such as passwords or API keys with anyone.
How do I format JSON online?
Paste your JSON into the Input box (or drop a .json file). The Output box shows it beautified straight away. Choose Beautify, Minify, Sort keys or a different indent size at any time, then copy or download the result.
How do I find the error in my JSON?
The status bar shows whether the code is valid. If it is not, you get the line and column, a short explanation and a code frame that marks the exact spot. Press Jump to error to select it in the editor.
What does Auto-fix repair?
It removes comments, converts single quotes to double quotes, adds quotes around property names, removes trailing commas, adds missing commas between properties, lower-cases True, False and None, replaces undefined, NaN and Infinity with null, and tidies number formats. It lists every change it made, so check the result before you use it.
How does JSON to XML conversion work?
Each key becomes an element. Keys that start with @ become attributes and #text becomes the element's text. Arrays become repeated elements with the same name, and null becomes an empty element. A JSON document with several top-level keys is wrapped in a <root> element.
How does XML to JSON conversion work?
Attributes become keys that start with @, text becomes a string (or #text when the element also has attributes or children), and repeated elements become an array. All values come out as text, because XML has no number or boolean types.
Does it change my numbers?
No. Numbers are kept exactly as you wrote them, so a very long ID like 12345678901234567890 is not rounded the way JavaScript would round it.
Does it support comments or JSON5?
Strict validation follows the JSON standard, so comments, trailing commas and single quotes are reported as errors. Switch on Auto-fix to turn JSON5-style or JavaScript-style text into valid JSON.
How large a file can I use?
Up to about 10 MB of text. Very large results are not drawn on the page, but Copy and Download still work. The tree view is limited to 40,000 nodes.
Is it free?
Yes. The JSON and XML formatter is free to use with no signup.