JSON Formatter & Validator
JSON को सुंदर बनाएँ, मिनिफ़ाई करें और हर एरर की सटीक पंक्ति के साथ वैलिडेट करें। सब कुछ लोकल तौर पर चलता है — कुछ भी अपलोड नहीं होता।
- इनपुट
- JSON
- आउटपुट
- Formatted JSON · minified JSON · error location
Input
164 B · 1 line
Result
221 B (+35%) · 9 keys · depth 2
{
"id": 12345678901234567890,
"name": "Pack Camo",
"tags": [
"privacy",
"offline"
],
"price": 1.50,
"active": true,
"owner": {
"name": "Ada",
"email": "ada@example.com"
},
"notes": null
}Format, validate and repair JSON in one place
This JSON formatter turns a one-line API response into readable, indented JSON as you paste it, and validates it at the same time. If the JSON is broken it tells you what is wrong and on which line and column, highlights the line, and offers to repair the usual suspects: trailing commas, single quotes, unquoted keys and comments. You can minify instead, sort keys alphabetically at every level, and copy or download the result. It all runs in your browser, so tokens, customer records and internal configs never leave your machine.
How to format and validate JSON
- Paste JSON into the left pane, open a
.jsonfile, or drop one onto the pane. - Read the status bar: Valid JSON, or the error with its line and column. Press Go to error to jump to it.
- If the problem is a trailing comma, single quotes, unquoted keys or comments, press Repair to turn the text into strict JSON.
- Choose Beautify with 2 spaces, 4 spaces or tabs, or Minify, and switch on Sort keys if you want a stable order.
- Copy the result, download it as a
.jsonfile, or send it to another tool.
What makes JSON valid
JSON (RFC 8259) is stricter than the JavaScript it came from. Keys must be strings in double quotes; strings use double quotes too; there are no comments, no trailing comma after the last item, no undefined, NaN or Infinity, and numbers cannot have leading zeros or a bare decimal point. The validator checks every one of these rules and reports the first one broken, with a plain explanation instead of a cryptic engine message.
Line and column numbers count from 1, as in code editors, so you can jump straight to the spot in your own editor as well.
- Unexpected character
- Something that cannot start a value, such as a stray letter, or a missing quote earlier in the line.
- Expected , or }
- Two properties without a comma between them, or a missing closing brace.
- Trailing comma
- A comma after the last item of an object or array, which JavaScript allows and JSON does not.
- Unterminated string
- A string with no closing quote, often a line break inside a string, which must be written as \n.
Repairing near-JSON
Much of what gets pasted as JSON is really a JavaScript object, JSON5 or a commented config file. The repair turns it into strict JSON: it removes // and /* */ comments, drops trailing commas, rewrites 'single-quoted' strings with double quotes, quotes bare keys, and replaces Python's True, False and None. It reads the text with a tokenizer, so commas and quotes inside strings are never touched, and it keeps the line layout so later errors still point at the right line.
It deliberately does not guess at structural mistakes such as a missing comma or bracket. Those have more than one possible fix, and the validator points you to them instead.
Formatting without changing your data
Many formatters run the text through JSON.parse and back, which quietly rounds large numbers (an ID like 12345678901234567890 loses its last digits), rewrites 1.50 as 1.5, and moves numeric keys to the top of every object. This tool parses JSON into its own tree that keeps every number exactly as written and every key in its original order, so the only thing that changes is whitespace, unless you ask it to sort the keys.
Sorting compares keys by code point, as jq -S does, at every level of nesting. Sorted, consistently indented JSON is the easiest to compare; to see what actually differs between two documents use the JSON diff tool, and to turn JSON into YAML, CSV or TOML use the data converter.
Beautify or minify?
- Beautify for reading, reviewing and committing: one value per line makes diffs in version control small and clear. Two spaces is the most common indent in JavaScript projects, four is common in Python and Java, and tabs let each reader choose the width.
- Minify for sending and storing: removing whitespace typically shrinks pretty-printed JSON by 10–30%, and the output pane shows the size before and after.
- The output pane also counts the keys and the nesting depth, a quick sanity check on an unfamiliar payload.
अक्सर पूछे जाने वाले सवाल
- How do I format JSON online?
- Paste the JSON into the left pane. It is validated and pretty-printed in the right pane straight away; pick 2 spaces, 4 spaces or tabs, then copy or download the result.
- How do I check if JSON is valid?
- Paste it in and read the status bar. It shows Valid JSON, or the first error with its line and column, and Go to error moves the cursor to it.
- Why is my JSON invalid?
- The most common causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, comments, and a missing comma between two properties. The first four can be fixed with the Repair button.
- Can JSON have comments?
- No. Standard JSON has no comment syntax. JSONC and JSON5, used by some config files, allow them; the Repair button removes them to produce standard JSON.
- Does formatting change my numbers or key order?
- No. Numbers are written exactly as they appear in the input, including very large integers and trailing zeros, and keys stay in their original order unless you turn on Sort keys.
- How do I minify JSON?
- Choose Minify. All whitespace outside strings is removed, and the output pane shows how much smaller the result is.
- Is my JSON sent to a server?
- No. Parsing, validation and formatting all run in your browser. Nothing is uploaded, so it is safe for API keys, tokens and personal data.