About JSON Formatter and Validator
This free JSON formatter and validator makes messy JSON readable, checks that it is valid, and tells you exactly where it is not. It needs no sign-up and runs in your browser, so the JSON you paste, which often holds real customer data or API responses, is never uploaded.
Paste your JSON and the tool checks it as you type. If it is valid, you see Valid JSON and can format it with 2 spaces, 4 spaces or tabs, minify it to a single line, sort its keys, or explore it as a collapsible tree where a click on any key copies its JSON path. If it is not valid, you get the line and column of the first error and a plain description, such as a trailing comma or a missing quote. When the mistake is one of the usual ones, an Auto-fix button repairs it for you.
There are also two conversions. Escape and unescape turn text into a JSON string literal and back, which is how you embed a block of text or an HTML snippet in JSON. To CSV turns an array of objects into a table you can open in a spreadsheet.
The validator is strict, as JSON is. Comments, trailing commas, single quotes, unquoted keys, NaN and undefined are all rejected, because they are not part of the JSON standard. It follows the JSON standard, so what it accepts is what JSON.parse accepts.
How to use JSON Formatter and Validator
- Paste your JSON into the box. The tool checks it as you type and shows Valid JSON or the error.
- Choose a tab: Format to pretty-print, Minify to remove whitespace, Validate to check only, Sort keys to order the keys, Tree to browse, Escape to make or read a JSON string, or To CSV for a table.
- For Format and Sort keys, choose the indent: 2 spaces, 4 spaces or Tab.
- If you see Invalid JSON at line and column, go to that position. For a common mistake, press Auto-fix and check the result.
- In Tree, open and close branches, and click a key to copy its JSON path, such as $.users[0].name.
- Use Copy to take the output, or Download to save it as a .json file (a .csv file for To CSV).
Features
- Pretty-print with 2 spaces, 4 spaces or tabs.
- Minify to a single line with no extra whitespace.
- Validation that reports the line, the column and a plain-English message for the first error.
- Auto-fix for single quotes, unquoted keys, trailing commas and comments. The button only appears when the repaired text is valid.
- Tree view with collapsible branches, item counts and one-click copy of the JSON path of any key.
- Sort keys alphabetically at every level, without changing array order.
- Escape and unescape a JSON string. Unescape reads Unicode escapes, including emoji pairs.
- JSON to CSV for an array of objects, with the union of all keys as the header.
- Copy and Download of the result.
- All processing happens in your browser tab, with no server round trip.
Worked examples
{"user":{"id":7,"name":"Ada Lovelace","roles":["admin","dev"],"active":true,"manager":null}}, Format with 2 spaces gives { "user": { "id": 7, "name": "Ada Lovelace", "roles": [ "admin", "dev" ], "active": true, "manager": null } }
One long line becomes an indented block. The data is the same.
{ "user" : { "id" : 7, "roles" : [ "admin", "dev" ] } }, Minify gives {"user":{"id":7,"roles":["admin","dev"]}}
All whitespace between tokens is removed.
{"a": 1 "b": 2} gives Invalid JSON at line 1, column 9: Unexpected character '"', expected ',' or '}'
A comma is missing between the two members.
{ "a": 1, "b": [1, 2,] } gives Invalid JSON at line 3, column 14: Trailing comma is not allowed
The line and column point at the closing bracket after the last comma.
{name: 'Ada', "tags": ["a","b",],}, then Auto-fix gives {"name": "Ada", "tags": ["a","b"]}
The unquoted key, the single quotes and both trailing commas are repaired.
$.users[0]["first name"] gives The JSON path copied from the Tree for a key that contains a space.
Keys that are valid names use dot form, others use brackets and quotes.
Common JSON errors and what causes them
| Mistake | Message | Fix |
|---|---|---|
| Trailing comma after the last item | Trailing comma is not allowed | Delete the final comma |
| Single quotes around a string | Unexpected character ''', expected a quoted key | Use double quotes |
| Key without quotes | Unexpected character 'n', expected a quoted key | Put the key in double quotes |
| Missing comma between members | Unexpected character '"', expected ',' or '}' | Add a comma |
| Comment such as // or /* */ | Unexpected character '/' | Remove the comment |
| NaN, undefined or Infinity | Unexpected character 'N' | Use null or a number |
| Number with a leading zero, such as 01 | Unexpected character '1', expected ',' or '}' | Write 1 |
| Missing closing bracket | Unexpected end of input, expected ',' or ']' | Add the missing bracket |
| Unclosed string | Unterminated string | Add the closing double quote |
| A real line break inside a string | Control character in string (use \n) | Write \n instead of the line break |
JSON data types
| Type | Example | Note |
|---|---|---|
| String | "hello" | Always double quotes |
| Number | 42, -3.5, 1e6 | No leading zeros, no NaN, no Infinity |
| Boolean | true, false | Lowercase only |
| Null | null | Lowercase only |
| Array | [1, 2, 3] | Ordered list |
| Object | {"key": "value"} | Keys must be strings in double quotes |
Good to know
What auto-fix does and does not do
Auto-fix repairs the four most common things people copy from code and config files: single-quoted strings, unquoted keys, comments and trailing commas. It then checks that the result is valid, and offers the button only if it is. It cannot guess what is missing: a missing bracket, a missing value or a lost comma between members have to be fixed by hand, using the line and column in the message.
Review the repaired text before you rely on it. Auto-fix changes the text only, and it does not know your intent.
Large numbers and duplicate keys
The tool reads numbers the way JavaScript does, as 64-bit floating point. A whole number beyond 9007199254740991 loses precision: 12345678901234567890 is shown as 12345678901234567000. If your JSON holds big identifiers, such as snowflake IDs, keep them as strings before formatting.
If an object repeats a key, such as {"a":1,"a":2}, the parser keeps the last value, so the formatted output shows {"a":2}. Check for duplicates in the source if that surprises you.
Format, minify and validate are the same data
Formatting and minifying change only whitespace. They are safe to apply in either direction, and the data stays the same apart from the two cases above. Minified JSON is smaller to send and store. Formatted JSON is easier to read and to compare in a diff.
Privacy: how it works
- Your JSON is processed by code in your browser tab. Nothing is sent to Ulkaa or to any other server, which you can confirm in the Network tab of your browser developer tools.
- API responses, config files and database exports often contain tokens, emails and personal data, so a formatter that does not upload them is the safe kind to paste into.
Tips
- Fix the first error only, then look again. Later errors often vanish, because one missing quote can make everything after it look wrong.
- Sort the keys of two JSON files with the same settings before you compare them. A text diff then shows only the real differences.
- Use the Tree view to find a path, then copy it. That is quicker than counting brackets in a long response.
- To put text with quotes and line breaks into a JSON field, paste it in Escape and copy the result between the quotation marks.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your JSON are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your JSON are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
How do I format JSON?
Paste your JSON, choose the Format tab and an indent of 2 spaces, 4 spaces or Tab. The result appears below. Use Copy or Download to take it.
How do I validate JSON?
Paste it in. The tool checks it as you type. A valid document shows Valid JSON, and an invalid one shows the line, the column and the cause of the first error.
What causes an Unexpected token error?
The parser found a character that JSON does not allow at that point, such as a trailing comma, a single quote, an unquoted key or a stray character. Look at the line and column in the message.
Can JSON have comments?
No. Standard JSON has no comment syntax. The validator rejects them, and Auto-fix can strip // and /* */ comments for you.
How do I minify JSON?
Paste it in and choose the Minify tab. The tool removes the whitespace between tokens and leaves the data unchanged.
How do I copy the path of a value?
Open the Tree tab and click the key. The JSON path, such as $.users[0].name, is copied to your clipboard.
How do I escape a string for JSON?
Choose the Escape tab and paste your text. Quotes, backslashes and line breaks are escaped, and you can paste the result between double quotes. Tick Unescape instead to reverse it.
Is there a size limit?
There is no upload, so no upload limit. Very large documents, in the tens of megabytes, can make a browser tab slow. For big files to CSV, use the dedicated JSON to CSV converter in the File tools.
Popular JSON Formatter and Validator pages
- JSON ValidatorCheck that your JSON is valid and find the first error by line and column.
- JSON MinifierRemove the extra whitespace from JSON to make it smaller.
- JSON BeautifierPretty-print JSON so it is easy to read.
- JSON ViewerExplore JSON as a collapsible tree and copy the path of any value.
- JSON LintLint your JSON, find the error, and fix the usual mistakes.
- JSON Escape and UnescapeEscape quotes, backslashes and line breaks for JSON, or turn an escaped string back into plain text.
- JSON Key SorterSort the keys of every object in your JSON alphabetically.
- JSON to CSV ConverterTurn a JSON array of objects into a CSV table you can open in a spreadsheet.