Runs entirely in your browser. Nothing you paste is uploaded or stored.
How to format JSON online
- Paste your JSON into the left editor, open a
.jsonfile, or click Sample to try it. - Click Format / Beautify to indent it with 2, 3 or 4 spaces or tabs. Tick Sort keys A-Z to order every object's keys alphabetically.
- Click Minify / Compact to strip all whitespace for an API request or a config value.
- Click Validate to check the syntax. If something is wrong, the error line is marked in the editor and the cursor jumps to it.
- Use Convert JSON to for XML, YAML or CSV, then Copy or Download the result.
What is JSON?
JSON (JavaScript Object Notation) is the most common format for sending data between a browser, a server and third-party APIs. It is plain text built from two structures: objects, which are {"key": value} pairs, and arrays, which are ordered lists like [1, 2, 3]. Values can be strings, numbers, true, false, null, or more objects and arrays.
Because APIs usually return JSON minified on a single line, it is hard to read when you are debugging. A formatter adds indentation and line breaks so you can see the structure at a glance, spot a missing field, or compare two responses.
Common JSON errors and how to fix them
JSON looks like a JavaScript object, but the rules are much stricter. These mistakes cause most validation failures:
- Trailing commas.
{"a": 1,}is invalid. Remove the comma after the last item in an object or array. - Single quotes. Strings and keys must use double quotes:
{"name": "Ali"}, not{'name': 'Ali'}. - Unquoted keys.
{name: "Ali"}works in JavaScript but not in JSON. - Comments. JSON has no
//or/* */comments. Remove them before parsing. - Invalid values.
undefined,NaN,Infinityand functions are not allowed. Usenullinstead. - Unescaped characters. A double quote or backslash inside a string must be escaped as
\"or\\, and line breaks as\n.
Format vs minify: when to use each
Use the formatted version while you develop, review pull requests or write documentation, because people need to read it. Use the minified version in production payloads, environment variables and anything stored at scale, because every removed space saves bytes. Both versions contain exactly the same data, so you can switch between them freely.
Converting JSON to XML, YAML and CSV
YAML is handy for config files such as Docker Compose, Kubernetes and GitHub Actions. XML is still required by many older enterprise and SOAP APIs. CSV opens straight in Excel or Google Sheets: convert an array of objects and each object becomes a row, with nested fields flattened into columns like address.city.
Sending form data as JSON
Many sites submit forms with fetch() and a JSON body instead of a classic form post. A form backend such as formvoxo accepts both, so you can post JSON from JavaScript and still get every submission by email:
fetch('https://www.formvoxo.com/f/YOUR_FORM_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify({ name: 'Ali', email: '[email protected]', message: 'Hello' })
});
See the documentation for AJAX submissions and the fields formvoxo reserves.
Want the full guide? Read How to Format and Validate JSON (and Fix the 7 Most Common Errors).
Frequently asked questions
Is my JSON sent to a server? +
No. Formatting, minifying and validation all happen in your browser with JavaScript. Nothing you paste is uploaded or stored.
Why does my JSON fail to validate? +
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, comments, and values like undefined or NaN. JSON is stricter than JavaScript object syntax.
What is the difference between formatting and minifying? +
Formatting (beautifying) adds line breaks and indentation so people can read the data. Minifying removes all unnecessary whitespace so the payload is as small as possible for APIs and storage.
Can I sort JSON keys alphabetically? +
Yes. Turn on "Sort keys" before formatting and every object, including nested ones, is output with its keys in alphabetical order. Arrays keep their original order.
How big a file can I format? +
It depends on your device memory, but a few megabytes of JSON format instantly in any modern browser.
More free tools
Need a backend for your HTML forms?
Point any form at formvoxo and get submissions in your inbox, with spam filtering built in. Free plan, no server code.
Create free account →